Moving Multiple Labels
-
I'm trying to create an interesting opening to an encryption program that I'm writing. If anyone has seen The Matrix(Who hasn't?), I'm trying to recreate the effect of those screens that have those different characters scroll down the screen. What I've done is created 21 labels on the top of my form. I create a random number from 1 to 255 so it will be used to change the individual labels. For Example : lblLabel1.text = Chr(RandomNumber) right after this command, I move the label down by 8 pixels. For Example: lblLabel1.top = lblLabel1.top + 8 I have assigned 21 timers for 21 different labels. My question is: Is there anyway that I can use a For Next loop to scroll through each label on my form instead of making all those timers? I tried making an array before, but I'm getting an error. I made the array as a public declaration Example: Public Label(20) as Label Then, when I try to have the timer go through each one, it gives me a syntax error? What should I do? What am I doing wrong? Sorry so long! Thanks for your time;P The Jazz Master 6000 DJ Badknees Parma Grind Crew - www.geocities.com/parmagrindcrew
-
I'm trying to create an interesting opening to an encryption program that I'm writing. If anyone has seen The Matrix(Who hasn't?), I'm trying to recreate the effect of those screens that have those different characters scroll down the screen. What I've done is created 21 labels on the top of my form. I create a random number from 1 to 255 so it will be used to change the individual labels. For Example : lblLabel1.text = Chr(RandomNumber) right after this command, I move the label down by 8 pixels. For Example: lblLabel1.top = lblLabel1.top + 8 I have assigned 21 timers for 21 different labels. My question is: Is there anyway that I can use a For Next loop to scroll through each label on my form instead of making all those timers? I tried making an array before, but I'm getting an error. I made the array as a public declaration Example: Public Label(20) as Label Then, when I try to have the timer go through each one, it gives me a syntax error? What should I do? What am I doing wrong? Sorry so long! Thanks for your time;P The Jazz Master 6000 DJ Badknees Parma Grind Crew - www.geocities.com/parmagrindcrew
Dim objLabel As Control For Each objLabel In Me.Controls If TypeOf objLabel Is Label Then MsgBox(objLabel.Name) '////do your code here for that label End If Next
not sure if thats the sort of thing you are after? you could then have 1 function to loop through each label rather than 20 odd sets of timers etc... and you could use sleep function inplace of timers for that functionSystem.Threading.Thread.Sleep(20)'/// your time where it says 20.
switch(twinsOnWay). { case ("twins on the way"): MessageBox.Show("for mr and mrs dynamic","twins on the way"); break; }
-
Dim objLabel As Control For Each objLabel In Me.Controls If TypeOf objLabel Is Label Then MsgBox(objLabel.Name) '////do your code here for that label End If Next
not sure if thats the sort of thing you are after? you could then have 1 function to loop through each label rather than 20 odd sets of timers etc... and you could use sleep function inplace of timers for that functionSystem.Threading.Thread.Sleep(20)'/// your time where it says 20.
switch(twinsOnWay). { case ("twins on the way"): MessageBox.Show("for mr and mrs dynamic","twins on the way"); break; }
Thank You! That was the kind of for next loop I was looking for. The only thing is, I have other labels on the form that do not need to be moved down (only label1 through label21). How can I only loop through labell through label21? The Jazz Master 6000 DJ Badknees Parma Grind Crew - www.geocities.com/parmagrindcrew
-
Thank You! That was the kind of for next loop I was looking for. The only thing is, I have other labels on the form that do not need to be moved down (only label1 through label21). How can I only loop through labell through label21? The Jazz Master 6000 DJ Badknees Parma Grind Crew - www.geocities.com/parmagrindcrew
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Dim objLabel As Control For Each objLabel In Me.Controls If TypeOf objLabel Is Label Then If objLabel.Name = "Label" > "0" < "21" Then MoveLabel(objLabel) End If End If Next End Sub Public Function MoveLabel(ByVal lbl As Label) Dim i As Integer Dim j As Integer = lbl.Top For i = 1 To 60 j = j + +1 lbl.Top = j System.Threading.Thread.Sleep(20) Next End Function
that moves 20 label 1 at a time in a smooth scroll , you can change the time of scroll on the sleep section.:)switch(twinsOnWay).
{
case ("twins on the way")://not long now
MessageBox.Show("for mr and mrs dynamic","twins on the way");
break;
} -
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Dim objLabel As Control For Each objLabel In Me.Controls If TypeOf objLabel Is Label Then If objLabel.Name = "Label" > "0" < "21" Then MoveLabel(objLabel) End If End If Next End Sub Public Function MoveLabel(ByVal lbl As Label) Dim i As Integer Dim j As Integer = lbl.Top For i = 1 To 60 j = j + +1 lbl.Top = j System.Threading.Thread.Sleep(20) Next End Function
that moves 20 label 1 at a time in a smooth scroll , you can change the time of scroll on the sleep section.:)switch(twinsOnWay).
{
case ("twins on the way")://not long now
MessageBox.Show("for mr and mrs dynamic","twins on the way");
break;
}Hell Yeah! Thanks a lot for your help! I owe you one The Jazz Master 6000 DJ Badknees Parma Grind Crew - www.geocities.com/parmagrindcrew
-
Hell Yeah! Thanks a lot for your help! I owe you one The Jazz Master 6000 DJ Badknees Parma Grind Crew - www.geocities.com/parmagrindcrew