Timer Problem

Erdenmandal
04-06-2004, 01:23 AM
Hi All

I use 8 timer. There is a Timer called timer_WarteZeit. a Support is just wait a few second before starting a program. After than it never comes again. But during a degugging process it appears again and again. But not always, sometimes :confused:
The code is :



Private Sub Start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Start.Click
ShowResult = 0
timer_WarteZeit.Enabled = True
End Sub




Private Sub timer_Blitzzeit_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timer_Blitzzeit.Tick
If (mStimulanz.GetisBegin = 0) Then
RightBild.Visible = False
Else
LeftBild.Visible = False
End If

timer_Blitzzeit.Enabled = False
timer_IntervalZeit.Enabled = True
end sub


Private Sub timer_IntervalZeit_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timer_IntervalZeit.Tick

timer_IntervalZeit.Enabled = False
timer_Timer1.Enabled = False

If myLevel.getLeft_Left Then
mStimulanz.IncreaseFlashTime()

If (mStimulanz.GetFlashtime = myLevel.getFlashAnzahl) Then
timer_LRLatenz.Enabled = True
Else
Draw()
End If

Else
If (mStimulanz.GetDrawNumber = 2) Then
timer_LRLatenz.Enabled = True
Else
If (mStimulanz.GetisBegin = 0) Then
mStimulanz.setisBegin(1)
Else
mStimulanz.setisBegin(0)
End If
Draw()
End If

End If
End Sub

Private Sub timer_LRLatenz_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timer_LRLatenz.Tick

timer_LRLatenz.Enabled = False
If myLevel.getLeft_Left Then
If (mStimulanz.GetDrawNumber > myLevel.getFlashAnzahl) Then
timer_BildTimer.Enabled = True
Else
If (mStimulanz.GetisBegin = 0) Then
mStimulanz.setisBegin(1)
Else
mStimulanz.setisBegin(0)
End If
mStimulanz.setFlashTime(0)
Draw()
End If
Else
mStimulanz.IncreaseFlashTime()

If (mStimulanz.GetFlashtime = myLevel.getFlashAnzahl) Then
timer_BildTimer.Enabled = True
Else
Randomize()
mStimulanz.setisBegin(Int(2 * Rnd()))
mStimulanz.setDrawNumber(0)
Draw()
End If
End If
end sub

Private Sub Draw()

mStimulanz.Draw(LeftBild, RightBild)

TimeIntervalAfterStart = 0

timer_Timer1.Start()
timer_Blitzzeit.Start()
timer_RightTime.Start()
timer_WarteZeit.Stop()

End Sub



Private Sub working_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown

If (timer_RightTime.Enabled) And (e.KeyCode = 32) Then


timer_RightTime.Stop()
timer_Timer1.Stop()

If Not mStimulanz.CreateResult() Then
Me.BackColor = System.Drawing.Color.Yellow
timer_ChangeBackColor.Start()
End If

End If

End Sub


Private Sub timer_RightTime_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timer_RightTime.Tick

timer_RightTime.Stop()
End Sub

Private Sub timer_ChangeBackColor_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timer_ChangeBackColor.Tick

timer_ChangeBackColor.Stop()
Me.BackColor = System.Drawing.Color.Black

End Sub

Private Sub timer_BildTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timer_BildTimer.Tick

Dim ret As Long


timer_BildTimer.Stop()

mStimulanz.IncreaseZyklusTime()

If (mStimulanz.isFinish()) Then
Dim dmd As New mMenu
' Bild.Enabled = False
Me.Visible = False
dmd.Show()
Else

mStimulanz.ChangeImage()
mStimulanz.setFlashTime(0)
Randomize()
mStimulanz.setisBegin(Int(2 * Rnd()))
mStimulanz.setDrawNumber(0)
Draw()

End If

End Sub



Private Sub timer_Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timer_Timer1.Tick
TimeIntervalAfterStart = TimeIntervalAfterStart + 1
End Sub

Private Sub timer_WarteZeit_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timer_WarteZeit.Tick

timer_WarteZeit.Stop() ' :confused: :confused: :confused: :confused: I wrote here Stop. But it does not work
ShowResult = 1
Randomize()
mStimulanz.setisBegin(Int(2 * Rnd()))
mStimulanz.setZyklusTime(0)
mStimulanz.setDrawNumber(0)
mStimulanz.setFlashTime(0)
Draw()


)
End Sub


Please help me to fix this problem

Erdenmandal
04-06-2004, 03:29 AM
At least I found a reason. IT because of a VB net . I feel this is one of a differences between VB. 6 and VB net.

In button Visible properties. in VB6 . when Visible = false , it means it also enabled = false, But in VB net, it still activate behind.

Test :



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label1.Text = "Button has pressed"
Timer1.Start()
Button1.Visible = False
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Timer1.Stop()
Label1.Text = ""
End Sub


Test this code in VB6 and VB net. The result is different. VB net I should also use button1.Enabled = false. :huh:

Write this code and Press Space several time. In VB net you can still see "Button has pressed" text in Label1.

Good luck

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum