Results 1 to 9 of 9

Thread: Progress Bar? What's that?

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    57

    Smile

    I know I'll probably be stoned and thrown out of the forum for saying this but..
    *coughIdon'tknowhowtouseaprogressbarcough*
    umm
    Can someone hook me up with an example of using a progress bar? I usually try to figure stuff out on my own but I don't know a thing about the control except how to put it on my form
    Don't Stone me please!!
    -Brad

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Code:
    Private Sub Form_Load()
        Me.Show
        ProgressBar1.Min = 0
        ProgressBar1.Max = 100
        For i = 0 to 100
            ProgressBar1.Value = i
            DoEvents
        Next i
    End Sub
    Put that into your form and watch...
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    Code:
    pbProgress.Min = 0
    pbProgress.Max = 100
    
    pbProgress.Value = 0
    
    'Do something
    pbProgress.Value = 10
    pbProgress.Refresh
    
    'Do something more
    pbProgress.Value = 20
    pbProgress.Refresh

  4. #4

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    57

    Sweetness

    Thanx for the nfo
    Have you heard about a gradient progress bar? i have a copy of the code somewhere on this thing..

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Yep. I think I wrote one a while ago.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  6. #6
    Guest
    A progressbar can also measure action. Say for example, opening a text file:

    Code:
        x = FileLen("C:\file.txt")
        ProgressBar1.Min = 0
        ProgressBar1.Max = x
        For i = 0 To x
            ProgressBar1.Value = i
        Next i
        Open "C:\file.txt" For Input As #1
            Text1.Text = Input$(LOF(1), 1)
        Close #1
        ProgressBar1.Value = ProgressBar1.Max

  7. #7

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    57

    Question How does that measure action

    How would that measure action?>
    wouldn't the program just run through the loop
    jack the progress bar up to its max
    THEN open the file and making sure to set it at max again??
    -confused

  8. #8
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    or you can make your own progress bar..
    
    'example of a Picture1 bar using a picture box
    
    'make a standard app and add a picture box called Picture1
    'add a command button called Command1
    
    'in the PublicSub DoPicture1 and use Form1 as formname
    'cut and paste the code and run to see an example
    '
    '<<<<<<<  Put this in a bas module  >>>>>>>>
    
    Option Explicit
    
    'number of things to do ex..files to be backed up
    Public intCounted As Integer
    '
    Public Sub DoPicture1(Percent)
    '
    ' Percent is % of graph
    '
    Dim Work As Integer
    Dim Num As String
    '
    Work = Int(Abs(Percent))
    If Work > 100 Then Work = 100
    '
    With Form1.Picture1     '<<<   With application form
        .BackColor = vbWhite        '<<<   White background
        If Not .AutoRedraw Then     '<<<   picture in memory ?
        .AutoRedraw = True          '<<<   make one
        End If
        
        .Cls                        '<<<   clear picture in memory
        .ScaleWidth = 100           '<<<   new scalemodus
        .DrawMode = 10              '<<<   not XOR Pen Modus
    
        Num = Format$(Work, "###") + "% Completed"
    
        .CurrentX = 50 - .TextWidth(Num) / 2         '<<<  %age is Centered
    
        .CurrentY = (.ScaleHeight - .TextHeight(Num)) / 2
    
        Form1.Picture1.ForeColor = vbBlack     '<<<  Black text
        Form1.Picture1.Print Num               '<<<  print percent
    
        Form1.Picture1.Line (0, 0)-(Work, .ScaleHeight), vbBlue, BF
        .Refresh          '<<<  show
    End With
    '
    End Sub
    Option Explicit
    
    '  <<<<<<<<<<<<   event code for form   >>>>>>>>>>>>>>>>>>>
    
    Private Sub Command1_Click()
    
    Dim intTotalCount As Integer
    
    intTotalCount = 100   'whatever..use 1000 for this example
    
    'print the line & increment the count
    
    Dim i, copied
    
    For i = 1 To 100
     
        Print "This is a progress bar sample!"
        
        copied = copied + 1    'increment for progress bar
        Call DoPicture1(copied / intTotalCount * 100)   'progress bar set to 100
     Next i
    
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  9. #9
    Guest
    Bad example, here is a better one, it is used to make a progressbar for a Webbrowser.

    Code:
    Private Sub WebBrowser1_ProgressChange(ByVal Progress As Long, ByVal ProgressMax As Long)
    On Error Resume Next
    Progressbar1.Min = 0
    Progressbar1.Max = ProgressMax
    Progressbar1.Value = Progress
    End Sub
    Well, the example above will open a file. The Progressbar's Max size will become the Text file's size.
    The Progressbar will start counting up to the file size. During this process, the file will be put into a text file. And finally, after it has finished, the progressbar's value is all filled in. Makes it look like it measures action. Sorry for giving the wrong information.

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