Label appears after 10 seconds

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jamie Taxer
    New Member
    • Oct 2011
    • 6

    Label appears after 10 seconds

    Hi,

    I have been searching the internet and this forum for the answer to my problem, but so far nothing is working. I want a label to appear 10 seconds after the form loads. This is one of the codes that I have tried so far


    Code:
    Private Sub Form_Load()
            Timer1.Interval = 60000
            Timer2.Interval = 10000
            
     End Sub
    
    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
            Static Flag As Integer
            Flag = Flag + 1
            If Flag = 1 Then
                Label2.Visible = False
            Else
                Label2.Visible = True
            End If
            Flag = 0
    End Sub
    but it doesn't work. Like this the label is visible when the form loads and then disappears, but if I switch the Label2.Visible = True & False the code doesn't work at all. It also doesn't do anything if I change the = to a less than sign. Any and all help is appreciated. Thanks!
    Last edited by Frinavale; Oct 31 '12, 04:19 PM. Reason: Added code tags
  • Asprisa
    New Member
    • Oct 2007
    • 30

    #2
    Hi,

    I assume you have timer2.start() in the form_load?

    Also in the tick event, flag has not been set to anything, i would first assign Flag a value like 0, but then your code says flag = flag + 1 so the value would be 1, meaning the value of the label would be set to visible = false, and at the end of the event Flag is set back to 0, meaning the value would only ever be 1 or visible = false.

    I do not know what the Flag does, but maybe you try
    Code:
    Static Flag As Integer
    Flag = Flag + 1
    If Flag = 1 Then
        Label2.Visible = False
    Elseif Flag = 0 OR Flag > 1
        Label2.Visible = True
    End If
    Flag = 0

    Let me know if this helps.

    James.
    Last edited by Frinavale; Oct 31 '12, 04:21 PM. Reason: Added code tags

    Comment

    • Jamie Taxer
      New Member
      • Oct 2011
      • 6

      #3
      Thanks for your help, but I actually already got it to work with the code below.
      Code:
      Private Sub AnagramExample_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
          Word.Visible = False
          Timer2.Interval = 10000
          Timer2.Enabled = True
      End Sub
      
      Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
          Word.Visible = True
          Timer2.Enabled = False
      End Sub
      Last edited by Frinavale; Oct 31 '12, 04:21 PM. Reason: Added code tags.

      Comment

      • waliasunil1
        New Member
        • Oct 2012
        • 1

        #4
        helo neccessary info u have posted

        thanx friend it was rally good info.

        Comment

        Working...