Problem med Timer1_Timer
Det er sikkert meget banalt, men ikke for en newb...Jvf. http://www.eksperten.dk/spm/573703 prøver jeg at lave et filflytteprog, der flytter alle filer fra en mappe til en anden hvert 30. sek. Derfor prøver jeg at få noget Timer til at køre og jeg har fundet lidt stumper her på Eksperten, men jeg får ikke afviklet koden i Timer1_Timer sub'en (hedder det det?). Hvad gør jeg forkert? (Jeg har pastet al koden incl. det der automatisk er genereret af MS VB .Net 2003 (Det i starten))
Tnx!
Option Explicit On
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Timer1 As System.Windows.Forms.Timer
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(80, 216)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 0
Me.Button1.Text = "Button1"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(168, 216)
Me.Button2.Name = "Button2"
Me.Button2.TabIndex = 1
Me.Button2.Text = "Button2"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 272)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 2000 '<- Speed
Button2.Enabled = False
End Sub
Private Sub Timer1_Timer()
Static intCount As Integer
intCount = intCount + 1
If intCount = 1 Then
MsgBox("{LEFT}", True)
Else
MsgBox("{RIGHT}", True)
intCount = 0
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Enabled = True
Button1.Enabled = False
Button2.Enabled = True
MsgBox("Tryk1")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Enabled = False
Button2.Enabled = False
Button1.Enabled = True
MsgBox("Tryk2")
End Sub
End Class