Results 1 to 7 of 7

Thread: Waiting command

  1. #1

    Thread Starter
    Lively Member ARanc's Avatar
    Join Date
    Aug 2006
    Posts
    71

    Waiting command

    Hi everyone,

    I have several buttons and a 2 picture boxes. When you press any button, a certain image on the web is showed in the first picture box.

    The second picture box is invisible I use to display a loading image.

    What I want to do is that when you press a button it will make the second picture box visible and display for about 3 seconds.

    I tried this but it wont work

    Any help would be great

    Code:
    PictureBox2.Visible = True
    Me.PictureBox1.ImageLocation = "http://i.cnn.net/cnn/.element/img/1.0/weather/accu/samsat.png"
    Threading.Thread.Sleep(2000)
    PictureBox2.Visible = False
    I use vb.net express 2005

    Regards,

    Alex

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: Waiting command

    Well if you really want to put the thread to sleep, check this thread. But I would really advice you to use a Timer instead.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Waiting command

    You only need one PictureBox to do this. Set the InitialImage property of the PictureBox to a local image, then do this:
    Code:
    Me.PictureBox1.LoadAsync("http://i.cnn.net/cnn/.element/img/1.0/weather/accu/samsat.png")
    The PictureBox will display your InitialImage while the main image is loading, then replace it once the main image has finished downloading.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Lively Member ARanc's Avatar
    Join Date
    Aug 2006
    Posts
    71

    Re: Waiting command

    Thanks guys

    jmcilhinney, its as if you read my mind. Thats what I wanted to do but though it was not possible, so I resorted to my other way.

    Thanks,

    Alex

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Waiting command

    Quote Originally Posted by ARanc
    Thanks guys

    jmcilhinney, its as if you read my mind. Thats what I wanted to do but though it was not possible, so I resorted to my other way.

    Thanks,

    Alex
    Yeah, reading minds is why JM decided to use "apprentice idiot" as his user title. I haven't figured it out yet, though I assume it is some kind of zen thing.
    My usual boring signature: Nothing

  6. #6

    Thread Starter
    Lively Member ARanc's Avatar
    Join Date
    Aug 2006
    Posts
    71

    Re: Waiting command

    Jim,

    I tried what you did but it did not work.

    The problem is that each button when pressed is referring to the same image location. When I first run the program the initial image is shown. But once I press the other button , the first loaded image will show until the other one is loaded; no initial image is show. However, I did figure out a solution.

    Here is the code, I hope this might help someone

    Code:
    Me.PictureBox19.Image = Nothing
            Me.PictureBox19.LoadAsync("http://i.cnn.net/cnn/.element/img/1.0/weather/accu/samsat.png")
    Last edited by ARanc; Feb 27th, 2007 at 08:26 PM.
    Regards,

    Alex



    I use Visual Basic 2005 Express Edition

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Waiting command

    That's not A solution. It's THE solution.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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