Timer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • THEAF
    New Member
    • Mar 2007
    • 52

    Timer

    hi,
    im trying to call the form load after each 5 seconds. can enyone please look at my code and show me how to load the form after 5 seconds. thank you
    [code=vb]
    Private Sub Form_Load()
    lbl.Caption = "30"
    End Sub

    Private Sub Timer1_Timer()

    If lbl.Caption = 0 Then
    Timer1.Enabled = False
    MsgBox ("100 secs is up")
    Else
    lbl.Caption = lbl.Caption - 1
    End If
    If lbl.Caption = lbl.Caption ' And i dont know the rest
    Random
    End If
    End Sub

    Public Sub Random()
    Randomize
    Label4.Caption = Int(Rnd * 10)
    End Sub
    [/code]
    Plese help...
    Last edited by debasisdas; Feb 28 '08, 02:11 PM. Reason: added code=vb tags
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Tell me what exactly you are trying to do .

    Why you need to load the form every 5 seconds ?

    Comment

    • VBWheaties
      New Member
      • Feb 2008
      • 145

      #3
      I assume you mean you need to delay the visibility of the form for 5 seconds?

      Try this in your forms load event:
      Code:
      System.Threading.Thread.Sleep(5000) ' 5 seconds
      Last edited by VBWheaties; Feb 28 '08, 02:53 PM. Reason: Removed quoted text

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by VBWheaties
        System.Threadin g.Thread.Sleep( 5000) ' 5 seconds
        The original post looks to me like VB6 code, in which case this won't work as posted.

        THEAF, if you mean that you want the timer to load the form that it's on, this is impossible. Since the timer control exists within the form, it doesn't exist except while the form is loaded. It therefore cannot load that form. When the form is unloaded, no more timer.

        Are you sure you don't want to unload the form? Or do you want to load a different form, or what?

        Comment

        • THEAF
          New Member
          • Mar 2007
          • 52

          #5
          sorry,
          what it was, was that as the each 5 sec the public sub.. should be called to randomize a new number but it's ok now.

          Comment

          Working...