Results 1 to 12 of 12

Thread: progress bar..

  1. #1
    lOnEr is offline VB.NET Forum Newbie
    .NET Framework
    Join Date
    Jun 2004
    Posts
    14
    Reputation
    111

    progress bar..[resolve]

    hi..im very new in vb.net
    how to use progress bar in my apps..

    could someone guide me in this thing...

    thanks in advance..
    Last edited by lOnEr; 06-19-2004 at 3:28 AM.

  2. #2
    Michaelk is offline VB.NET Forum Enthusiast
    .NET Framework
    .NET 2.0 (VS 2005)
    Join Date
    Jun 2004
    Location
    Australia
    Posts
    58
    Reputation
    113
    I know how to run a progess bar based on a timer. But not sure about load times. Let me know if thats what your after.

  3. #3
    lOnEr is offline VB.NET Forum Newbie
    .NET Framework
    Join Date
    Jun 2004
    Posts
    14
    Reputation
    111
    Quote Originally Posted by Michaelk
    I know how to run a progess bar based on a timer. But not sure about load times. Let me know if thats what your after.
    halu thanks for the reply..
    what i want is when i click the button it will run the progress bar.

    tanx in advance..

  4. #4
    Michaelk is offline VB.NET Forum Enthusiast
    .NET Framework
    .NET 2.0 (VS 2005)
    Join Date
    Jun 2004
    Location
    Australia
    Posts
    58
    Reputation
    113

    Lightbulb

    Ok, use this to run a progess bar based on a timer.

    - You will need a timer called "time"
    - and a progess bar called "progressBar1"

    On the button_click put this:
    Code:
    
    ' Connect the Tick event of the timer to its event handler.
    AddHandler time.Tick, AddressOf IncreaseProgressBar
    ' Start the timer.
    time.Start()
    
    And put these 2 Private Subs in as well:
    Code:
    
    PrivateSub InitializeMyTimer()
    ' Set the interval for the timer.
    time.Interval = 100
    ' Connect the Tick event of the timer to its event handler.
    AddHandler time.Tick, AddressOf IncreaseProgressBar
    ' Start the timer.
    time.Start()
    EndSub
    
    and:

    Code:
    
    PrivateSub IncreaseProgressBar(ByVal sender AsObject, ByVal e As EventArgs)
    ' Increment the value of the ProgressBar a value of one each time.
    ProgressBar1.Increment(1)
    ' Display the textual value of the ProgressBar in the StatusBar control's first panel.
    statusBarPanel1.Text = ProgressBar1.Value.ToString() + "% Completed"
    ' Determine if we have completed by comparing the value of the Value property to the Maximum value.
    If ProgressBar1.Value = ProgressBar1.Maximum Then
    ' Stop the timer.
    time.Stop()
    'Put what you want to run after the progess bar is finished here.
    
    EndIf
    EndSub
    Hope thats what your after
    Good luck,

  5. #5
    lOnEr is offline VB.NET Forum Newbie
    .NET Framework
    Join Date
    Jun 2004
    Posts
    14
    Reputation
    111
    tanx for your effort...
    but im sorry to tell you this the code did not work..

    Code:
      Private Sub initializetimer()
      		Timer1.Interval = 100
      		AddHandler Timer1.Tick, AddressOf increaseprogress
      		Timer1.Start()
      	End Sub
      	Private Sub increaseprogress(ByVal sender As Object, ByVal e As EventArgs)
      		ProgressBar1.Increment(1)
      		StatusBarpanel1.Text = ProgressBar1.Value.ToString() + "%completed"
      		If ProgressBar1.Minimum = ProgressBar1.Maximum Then
      			Timer1.Stop()
      		End If
      	End Sub
      
     	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      		AddHandler Timer1.Tick, AddressOf increaseprogress
      	End Sub
    thanks..
    Last edited by lOnEr; 06-18-2004 at 10:32 PM.

  6. #6
    Michaelk is offline VB.NET Forum Enthusiast
    .NET Framework
    .NET 2.0 (VS 2005)
    Join Date
    Jun 2004
    Location
    Australia
    Posts
    58
    Reputation
    113
    Quote Originally Posted by lOnEr
    StatusBarpanel1.Text = ProgressBar1.Value.ToString() + "%completed"
    Opps, i think it may because of that line of code. That line makes a statusbar display the percentage of the progress bar. Try removing it.

  7. #7
    lOnEr is offline VB.NET Forum Newbie
    .NET Framework
    Join Date
    Jun 2004
    Posts
    14
    Reputation
    111
    what do you mean i will remove it??

    ok i already remove it but nothing happens..

  8. #8
    Paszt's Avatar
    Paszt is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Jun 2004
    Location
    Raleigh, NC - USA
    Posts
    1,502
    Reputation
    308
    If you could elaborate more on what you're trying to show the progress of, I'll be glad to attempt to help.

    Generally the progress bar is used to show the progress of something (obvious, I know). You would calculate the percent complete of whatever function you're doing and set the progressBar.Value property accordingly.

    In your code above you have the line 'If ProgressBar1.Minimum = ProgressBar1.Maximum Then'. The Minimum value will not usually ever equal the Maximum Value (the progressBar would serve no purpose if they were equal, though it is possible). The timer should never stop.
    — Stephen Paszt

  9. #9
    mzim's Avatar
    mzim is offline VB.NET Forum Genius
    .NET Framework
    .NET 2.0 (VS 2005)
    Join Date
    Jun 2004
    Location
    Other side of the rock
    Posts
    187
    Reputation
    115
    Originally deleted by the author
    I see dead people there everywhere and some of them
    they're here.



  10. #10
    lOnEr is offline VB.NET Forum Newbie
    .NET Framework
    Join Date
    Jun 2004
    Posts
    14
    Reputation
    111
    Quote Originally Posted by Paszt
    If you could elaborate more on what you're trying to show the progress of, I'll be glad to attempt to help.

    Generally the progress bar is used to show the progress of something (obvious, I know). You would calculate the percent complete of whatever function you're doing and set the progressBar.Value property accordingly.

    In your code above you have the line 'If ProgressBar1.Minimum = ProgressBar1.Maximum Then'. The Minimum value will not usually ever equal the Maximum Value (the progressBar would serve no purpose if they were equal, though it is possible). The timer should never stop.
    halu Paszt thanks in advance...
    heres what i want..
    i want to run a progressbar as well as status bar in app's by clicking a button..
    im very new in this thing.
    tanx and more power.

  11. #11
    mzim's Avatar
    mzim is offline VB.NET Forum Genius
    .NET Framework
    .NET 2.0 (VS 2005)
    Join Date
    Jun 2004
    Location
    Other side of the rock
    Posts
    187
    Reputation
    115
    Quote Originally Posted by lOnEr
    halu Paszt thanks in advance...
    heres what i want..
    i want to run a progressbar as well as status bar in app's by clicking a button..
    im very new in this thing.
    tanx and more power.
    Code:
     Public Sub progress()
     		StatusBar1.Text = "connecting to the database"
     		If ProgressBar1.Value = ProgressBar1.Maximum Then
     			ProgressBar1.Value = ProgressBar1.Maximum
     		End If
     		Dim i As Integer
     		For i = ProgressBar1.Minimum To ProgressBar1.Maximum
     			ProgressBar1.PerformStep()
     		Next
     	End Sub
     
     	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
     		progress()
     	End Sub
    set the progressbar1.maximum to 10000 and progressbar1.minimum to 1

    hope it helps..
    happy coding
    I see dead people there everywhere and some of them
    they're here.



  12. #12
    lOnEr is offline VB.NET Forum Newbie
    .NET Framework
    Join Date
    Jun 2004
    Posts
    14
    Reputation
    111
    Quote Originally Posted by mzim
    Code:
     Public Sub progress()
     		StatusBar1.Text = "connecting to the database"
     		If ProgressBar1.Value = ProgressBar1.Maximum Then
     			ProgressBar1.Value = ProgressBar1.Maximum
     		End If
     		Dim i As Integer
     		For i = ProgressBar1.Minimum To ProgressBar1.Maximum
     			ProgressBar1.PerformStep()
     		Next
     	End Sub
     
     	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
     		progress()
     	End Sub
    set the progressbar1.maximum to 10000 and progressbar1.minimum to 1

    hope it helps..
    happy coding
    hi..mzim thanks..it really works..


    more power...

Bookmarks

Posting Permissions

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