Welcome to Dream.In.Code
Become a VB Expert!

Join 149,477 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,804 people online right now. Registration is fast and FREE... Join Now!




Display labels in sequence

 
Reply to this topicStart new topic

Display labels in sequence

oldgolfer
5 May, 2007 - 04:54 PM
Post #1

New D.I.C Head
*

Joined: 13 Nov, 2006
Posts: 20



Thanked: 1 times
My Contributions
Hi, This is the problem, I wish to click on one button and with this one click display first label for 1 second then display second label and make first label disappear then display third label and make second label disappear As in label1 "Ready", Label2 "Steady", label3 "Go". I understand making labels visible with true or false but cannont get the delay. Thanks blink.gif
User is offlineProfile CardPM
+Quote Post

kyrotomia
RE: Display Labels In Sequence
5 May, 2007 - 05:27 PM
Post #2

D.I.C Head
**

Joined: 5 May, 2007
Posts: 50



Thanked: 1 times
My Contributions
Hi. I suggest you to use this code to achieve your needs :
CODE
Threading.Thread.Sleep(5000) 'Time in milliseconds, 5000 = 5 seconds

User is offlineProfile CardPM
+Quote Post

oldgolfer
RE: Display Labels In Sequence
5 May, 2007 - 06:13 PM
Post #3

New D.I.C Head
*

Joined: 13 Nov, 2006
Posts: 20



Thanked: 1 times
My Contributions
Hi, thanks but I must still be doing something wrong, with my code after clicking button there is a delay and only the last label shows. Am I missing somthing??? blink.gif
CODE
Public Class Test

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
        Label1.Visible = True
        Threading.Thread.Sleep(1000)
        Label1.Visible = False
        Label2.Visible = True
        Threading.Thread.Sleep(1001)
        Label2.Visible = False
        Label3.Visible = True
        Threading.Thread.Sleep(1002)
        Label3.Visible = True

    End Sub

End Class

thanks for any help
User is offlineProfile CardPM
+Quote Post

kyrotomia
RE: Display Labels In Sequence
5 May, 2007 - 06:27 PM
Post #4

D.I.C Head
**

Joined: 5 May, 2007
Posts: 50



Thanked: 1 times
My Contributions
Sorry for misleading you, I though the code would act similar to a Sleep command I have seen in .Net. I haven't tested the code before posting crazy.gif.

However, I tested this one and i guarantee it to work. You need to add a timer to your form and set the Interval (in miliseconds) to your needs. Now add this code to your Button1.Click event :
CODE

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer1.Enabled = True 'activates the timer
    End Sub


Add this code to your Timer1.Tick event
CODE

  Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        Static Dim Counter As Integer = 0 'static prevents the variable to dim at 0 each tick.
        Counter += 1

        Select Case Counter
            Case 1
                Me.Label1.Visible = True
            Case 2
                Me.Label1.Visible = False
                Me.Label2.Visible = True
            Case 3
                Me.Label2.Visible = False
                Me.Label3.Visible = True
            Case 4
                sender.enabled = False 'To prevent the timer from ticking again
        End Select
    End Sub

User is offlineProfile CardPM
+Quote Post

oldgolfer
RE: Display Labels In Sequence
5 May, 2007 - 07:31 PM
Post #5

New D.I.C Head
*

Joined: 13 Nov, 2006
Posts: 20



Thanked: 1 times
My Contributions
Thanks for that It works great, but, I hate to put a but in, but when I move to next page and then return to page one the button does not work. have tried Timer1.Enabled = False, or Timer1.Stop, everywhere I can think
CODE

Select Case Counter
            Case 1
                Me.Label1.Visible = True
            Case 2
                Me.Label1.Visible = False
                Me.Label2.Visible = True
            Case 3
                Me.Label2.Visible = False
                Me.Label3.Visible = True
            Case 4
                Me.Label3.Visible = False
            
            Case 5
                sender.enabled = False 'To prevent the timer from ticking again
                Me.Hide()
                TestPage2.Show()
        End Select

User is offlineProfile CardPM
+Quote Post

kyrotomia
RE: Display Labels In Sequence
5 May, 2007 - 07:35 PM
Post #6

D.I.C Head
**

Joined: 5 May, 2007
Posts: 50



Thanked: 1 times
My Contributions
Okay, When you get back to your form1 from form2 you would have to set the var Counter back to 0.

You could also set the var counter back to 0 as soon as you end the timer tick, the "case 5".

Hope it helps you out.
User is offlineProfile CardPM
+Quote Post

oldgolfer
RE: Display Labels In Sequence
5 May, 2007 - 07:51 PM
Post #7

New D.I.C Head
*

Joined: 13 Nov, 2006
Posts: 20



Thanked: 1 times
My Contributions
G'Day and many thanks, that works I can move on now. Hope all new members are as helpful as you biggrin.gif icon_up.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 02:59PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month