Results 1 to 7 of 7

Thread: [RESOLVED] Beginner needs a progress bar

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2005
    Posts
    104

    Resolved [RESOLVED] Beginner needs a progress bar

    I have little knowledge of visual basic so feel free to reply as if im stupid. Any way i have some how created a simple ping application but need to add a progress bar to reassure users. Could any one help in showing me what code i need to add and where.


    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2. If ComboBox.Text = "Hull MPLS" Then
    3. Dim p As New Process
    4. p.StartInfo.FileName = "ping.exe"
    5. p.StartInfo.Arguments = "172.16.0.1"
    6. p.StartInfo.CreateNoWindow = True
    7. p.StartInfo.UseShellExecute = False
    8. p.StartInfo.RedirectStandardOutput = True
    9. p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
    10. p.Start()
    11. With TextBox
    12. .Text = .Text & p.StandardOutput.ReadToEnd
    13. .SelectionStart = Len(.Text)
    14. .ScrollToCaret()
    15. End With
    16. p.WaitForExit()
    17.  
    18. End If

    Thanks

    Jason

  2. #2
    Lively Member
    Join Date
    Nov 2005
    Location
    Bristol/Bath
    Posts
    85

    Re: Beginner needs a progress bar

    Drag a progress bar onto your form and name it as appropriate. For the sake of reference i will call it progressBar1. The progress bar exposes the property maximum (max number of increments) and the method increment()

    set the max number of increments - eg if you perform 10 pings
    ProgressBar1.maximum = 10
    then for each ping you perform progressBar1.increment(1)

    hope this helps

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

    Re: Beginner needs a progress bar

    You can't really display a traditional progress bar unless you can give some indication of exactly what the progress is, which in your case you can't. Plus the fact that your app is frozen until WaitForExit returns. If you are using VB.NET 2005 then the ProgressBar has a Style property that you can set to Marquee to create an endless ProgressBar like the one displayed when Windows starts up.
    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
    Join Date
    Sep 2005
    Posts
    104

    Re: Beginner needs a progress bar

    Thats exactly what i want. Im not to bovered about the progress being in sync with the pinging. Its just to stop the inpatient users clicking away at buttons while it is performing its task. Is there no way of doing that in 2003 or will an upgrade to 2005 be the best plan of action?

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Sep 2005
    Posts
    104

    Re: Beginner needs a progress bar

    I have added the progress bar and set the style as marque. How do i get it to start the progress bar when the "ping" button is pressed?

    Thanks

    Jason

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

    Re: Beginner needs a progress bar

    You would set the Style to Blocks in the designer and make sure the Value is zero, which it is by default. You would then set the Style to Marquee in code when you wanted the animation to start and then back to Blocks when you want it to end.
    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

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Sep 2005
    Posts
    104

    Re: [RESOLVED] Beginner needs a progress bar

    Excellent!!!!

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