Results 1 to 5 of 5

Thread: Pausing the sequence

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2004
    Posts
    42

    Question Pausing the sequence

    Hi,

    Is it possible to make vb.net 'pause' for a few seconds before carrying on through the code. For example,

    on button click

    label1.text = "Hello"
    **Code here to pause for 2 seconds then...**
    label1.text = "This is my first post"
    **Code here to pause for 2 seconds then...**
    label1.text = "I dont know what I'm doing"

    etc etc

    any help on this would be great. I am quite new to this as you can tell.

    thanks a lot.

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Try this
    VB Code:
    1. label1.text = "Hello"
    2. Threading.Thread.Sleep(2000) ' 2 seconds delay
    3. label1.text = "This is my first post"
    4. Threading.Thread.Sleep(2000) ' 2 seconds delay
    5. label1.text = "I dont know what I'm doing"

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2004
    Posts
    42
    hi, thanks for your help

    i have tried this and it seems to just make everything wait for 2 seconds and then just posts the last label1.text

    for example

    label1.text = "Hello"
    Threading.Thread.Sleep(2000) ' 2 seconds delay
    label1.text = "This is my first post"
    Threading.Thread.Sleep(2000) ' 2 seconds delay
    label1.text = "I dont know what I'm doing"

    just waits a few seconds and then posts "I dont know what im doing" - i never get to see either "Hello" or "This is my first post"

    any ideas?!

  4. #4
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Originally posted by grandad
    hi, thanks for your help

    i have tried this and it seems to just make everything wait for 2 seconds and then just posts the last label1.text

    for example

    label1.text = "Hello"
    Threading.Thread.Sleep(2000) ' 2 seconds delay
    label1.text = "This is my first post"
    Threading.Thread.Sleep(2000) ' 2 seconds delay
    label1.text = "I dont know what I'm doing"

    just waits a few seconds and then posts "I dont know what im doing" - i never get to see either "Hello" or "This is my first post"

    any ideas?!
    The label needs updating each time. Try

    VB Code:
    1. Label1.Text = "Hello"
    2.         Label1.Update()
    3.         Threading.Thread.Sleep(2000) ' 2 seconds delay
    4.         Label1.Text = "This is my first post"
    5.         Label1.Update()
    6.  
    7.         Threading.Thread.Sleep(2000) ' 2 seconds delay
    8.         label1.text = "I dont know what I'm doing"
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2004
    Posts
    42
    Excelent, that works. Thanks very much.

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