Results 1 to 11 of 11

Thread: Adding wait times;Delays pauses ect.

  1. #1

    Thread Starter
    Addicted Member Reapism's Avatar
    Join Date
    Sep 2012
    Posts
    170

    Exclamation Adding wait times;Delays pauses ect.

    How do you add Delays, Pauses

    I am asking is there a way to say this

    If Textbox1.Text = "hi" Then
    [Adding delay here]
    Msgbox("Displaying here")

    Additional information.. Is there a way for me too add a delay with a If statement as shown above. Like making it count to 5 seconds or ect. before running the next line of code. I would really appreciate anything other then Timer's because those are very finicky and don't apply updates. I would prefer anything other then a ordinary timer. Thanks for all your support and feedback, It's invaluable.

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Adding wait times;Delays pauses ect.

    [Sits back, opens the popcorn, waits for the fun to begin!]
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,600

    Re: Adding wait times;Delays pauses ect.

    Thread.Sleep(5000) pauses for 5 seconds before continuing execution.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  4. #4

    Thread Starter
    Addicted Member Reapism's Avatar
    Join Date
    Sep 2012
    Posts
    170

    Re: Adding wait times;Delays pauses ect.

    I hope your having fun ;P

  5. #5

    Thread Starter
    Addicted Member Reapism's Avatar
    Join Date
    Sep 2012
    Posts
    170

    Re: Adding wait times;Delays pauses ect.

    Does this Freeze the Form?

  6. #6
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Adding wait times;Delays pauses ect.

    Quote Originally Posted by Reapism View Post
    Does this Freeze the Form?
    Oh yes. And it won't work on the main thread unless you import System.Threading!
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  7. #7

    Thread Starter
    Addicted Member Reapism's Avatar
    Join Date
    Sep 2012
    Posts
    170

    Re: Adding wait times;Delays pauses ect.

    o okay thanks! Wait is there another way I could do this that doesn't Freeze the form. It looks un-professional

  8. #8

    Thread Starter
    Addicted Member Reapism's Avatar
    Join Date
    Sep 2012
    Posts
    170

    Re: Adding wait times;Delays pauses ect.

    How do you import it doesnt let me "Where do I write this" and Thread.sleep is not even there.

  9. #9

    Thread Starter
    Addicted Member Reapism's Avatar
    Join Date
    Sep 2012
    Posts
    170

    Re: Adding wait times;Delays pauses ect.

    Hello everyone. I have no clue how to import the System.Threading and it wont go above the Public class. Is there any sort of way I can do this with the same functionallity without making the form freeze but if not Can you please let me know where to import in Visual Studio 2010

  10. #10
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Adding wait times;Delays pauses ect.

    vb.net Code:
    1. Imports System.Threading
    2.  
    3. Public Class Form1
    4.  
    5.     Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    6.         Thread.Sleep(5000)
    7.         Button1.Text = "Time Up"
    8.     End Sub
    9. End Class
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  11. #11

    Thread Starter
    Addicted Member Reapism's Avatar
    Join Date
    Sep 2012
    Posts
    170

    Re: Adding wait times;Delays pauses ect.

    Okay thank you so much! The program legit Freeze's and Since It does that there is no seamless delay and I was hoping to accomplish that. Is there some sort of way I can do so.

    Like here..
    It is actually going to wait for 4.5 Seconds and then after that I will be displayed with the buttons being visible. I was really hoping for something that didn't actually freeze the form simply for its unprofessionality and also It doesn't act the way as intended.
    Code:
        Private Sub BtnDisp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDisp.Click
            Thread.Sleep(1500)
            BtnAbout.Visible = True
            Thread.Sleep(1500)
            BtnWho.Visible = True
            Thread.Sleep(1500)
            BtnWhy.Visible = True
    First and for most I would like to thank you for helping but if you really really could help, If there is a way to add a delay without freezing Similar to the threading.
    Last edited by Reapism; Oct 27th, 2012 at 08:50 PM. Reason: I need to add some code :/

Tags for this Thread

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