VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



How to use PROGRESSBAR object in visual basic 6

by okoji cyril chidi (2 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 14th March 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

How to use PROGRESSBAR object in visual basic 6

Rate How to use PROGRESSBAR object in visual basic 6



' add two command button to the form
' Let the first command button be command1 or any desired name
' from the property change the caption to Foreward 
' let the second command button be command2
' From the property change the caption to End
' Fimally add the Microsoft Window common Control 6.0
' from Project Menu bar and menu item Component
' Add the ProgressBar control
' Change the object name to countingbar
Dim num As Long
Private Sub Command1_Click()
  CountingBar_Click ' call the progressbar routine
End Sub

Private Sub Command2_Click()
       DoEvents ' enable mouse while processing clic
       End ' terminate the program
End Sub

Private Sub CountingBar_Click()
    'CountingBar.Value = CountingBar.Value = Int(num / CountingBar.Max)
    'Command1.Caption = "Reverse"
    Dim t As Double, m(20000) As Double
    ' you can read the content of a file, process the file, process an image
    ' and lot more
    ' or using any other routine that requires keeping
    ' the user alive
    If Command1.Caption = "Foreward" Then
       num = 0
       CountingBar.Max = 20000 ' is the maximum record/file
       ' as the case may be
       Do While num <= CountingBar.Max - 1
       ' ASSUMING you want to read the content of a file or process
       ' a file the code should be here for example
       'If EOF(1) Then Exit Sub
       'Input #1, m,.....
       '.......more codes for the processing continue within
       ' the do loop
       num = num + 1 ' increament the counter
       If num <= CountingBar.Max Then
          CountingBar.Value = num ' assign the counter to the
          ' progress bar value
          ' it is this property that realy does the animation
       End If
       Form1.Caption = num & "  Number At " & Str(Int((num / CountingBar.Max) * 100)) + " %"
       ' display the progress bar percentage in the form's caption
       DoEvents ' enable mouse while processing click
       Loop
     '  Close
       Command1.Caption = "Reverse"
       ' toggles the push button
    
     Else
      ' reverse the direction of the progressbar
      num = 20000 ' The highest value or maximun value
      CountingBar.Min = 1 ' get the minimum value of the
      ' progress bar
      Do While num >= CountingBar.Min
      num = num - 1  'start decreasing the progress
      ' bar from the right hand side
      If num >= CountingBar.Min Then
         CountingBar.Value = num
           
      End If
      'For h = 1 To 10000000: Next h
      ' there may be  a need for  a delay if the operation is small
      Form1.Caption = num & "  Number At " & Str(Int((num / CountingBar.Max) * 100)) + " %"
     ' display the progress bar percentage in the form's caption
    DoEvents ' enable mouse while processing clic
    Loop
    Command1.Caption = "Foreward" ' toggles the caption again
                                  ' base on the operation
    End If
      
End Sub



Download this snippet    Add to My Saved Code

How to use PROGRESSBAR object in visual basic 6 Comments

No comments have been posted about How to use PROGRESSBAR object in visual basic 6. Why not be the first to post a comment about How to use PROGRESSBAR object in visual basic 6.

Post your comment

Subject:
Message:
0/1000 characters