Results 1 to 6 of 6

Thread: Display message with a delay?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    292

    Display message with a delay?

    Hi, everyone.

    My question is:


    How to display a message with a delay?

    Thanks.

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    292

    Re: Display message with a delay?

    Can someone help me on this.

  3. #3
    Frenzied Member litlewiki's Avatar
    Join Date
    Dec 2005
    Location
    Zeta Reticuli Distro:Ubuntu Fiesty
    Posts
    1,162

    Re: Display message with a delay?

    with a delay in the sense??
    add a timer set the interval for say 5 seconds then call the event
    just a wild idea!!

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    292

    Re: Display message with a delay?

    Can you give me a sample code?

  5. #5
    Frenzied Member litlewiki's Avatar
    Join Date
    Dec 2005
    Location
    Zeta Reticuli Distro:Ubuntu Fiesty
    Posts
    1,162

    Re: Display message with a delay?

    Code:
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    
    Private Sub Delay(ByVal delayInSeconds As Integer)
        Dim targetTime As Date
        targetTime = DateAdd("s", delayInSeconds, Now())
        While targetTime > Now
            Sleep 50 ' reduce CPU usage
            DoEvents ' keep app responsive
        Wend
    End Sub
    
    Private Sub Command1_Click()
    Delay (5)
    MsgBox "A"
    End Sub
    this will show your msgbox after 5 seconds
    __________________
    ________________0îîî___
    ___îîî0________(___)____
    __(___)_________) _/_____
    ___\_ (_________(_/______
    ____\_)_________________

  6. #6
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Display message with a delay?

    why not just use a timer as you originally suggested:

    VB Code:
    1. Private Sub Timer1_Timer()
    2.     MsgBox "TEST"
    3. End Sub
    4.  
    5. Private Sub Command1_Click()
    6.     Timer1.Interval = 5000
    7.     Timer1.Enabled = True
    8. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width