Looping using a lable and a timer

halljd39

New member
Joined
Sep 7, 2006
Messages
2
Programming Experience
1-3
Hello --

I am working on a simple project but I can't seem to get past a part of a loop procedure. Thought I could pick the brains of others...
So far I have the following code which move the lable up, but the down code does not loop for some reason - it does move down, though.

------------up-----------------

VB.NET:
Private Sub tmrUp_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmrUp.Tick
If lblVBnet.Top + lblVBnet.Height <= 0 Then
lblVBnet.Top = Me.Height
Else
lblVBnet.Top = lblVBnet.Top - lblVBnet.Height * 1 / 4
End If
End Sub
 
Private Sub btnUp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUp.Click
tmrUp.Enabled = True
End Sub
------------------down---------------
VB.NET:
Private Sub tmrDown_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrDown.Tick
If lblVBnet.Top + lblVBnet.Height >= 0 Then
lblVBnet.Top = Me.Height
Else
lblVBnet.Top = lblVBnet.Top + lblVBnet.Height * 1 / 4
End If
 
End Sub
 
Private Sub btnStopDown_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStopDown.Click
tmrDown.Enabled = False
End Sub
****The lable does move down but does not loop and I can't figure out what is going on.... any help would be great!!

Thanks!!
 
Last edited by a moderator:
I am having some trouble understanding what you are trying to do...

What do you mean by loop down etc? Are you trying to create a 'Credits' form that shows text that slides?
 
Private Sub tmrDown_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrDown.Tick
If lblVBnet.Top + lblVBnet.Height <= Me.Height Then
lblVBnet.Top = Me.Height
Else
lblVBnet.Top = lblVBnet.Top + lblVBnet.Height * 1 / 4
End If

End Sub
 
yes --- text should slide on the matrix based on pressing move up, move down, or move horizontal. For some reason --- the code that
pleh only moves when the code is changed to:

Private Sub tmrDown_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrDown.Tick
If lblVBnet.Top + lblVBnet.Height >= Me.Height Then
lblVBnet.Top = Me.Height
Else
lblVBnet.Top = lblVBnet.Top + lblVBnet.Height * 1 / 4
End If

End Sub

But, it still doesn't loop back to the top, so it should slide down then reappear at the top and then slide down again.
 
Private Sub tmrDown_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrDown.Tick
If lblVBnet.Top + lblVBnet.Height >= Me.Height Then
lblVBnet.Top = 0 ' the top is 0, me.height would mean the bottom
' causing it never to come back up.
Else
lblVBnet.Top = lblVBnet.Top + lblVBnet.Height * 1 / 4
End If

End Sub
 
Back
Top