Results 1 to 11 of 11

Thread: How Does Progress Bar Work?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2008
    Posts
    19

    How Does Progress Bar Work?

    Hey Guys , I just made a very small web browser but i got a problem , i want to attach a Progress Bar to it , so i made one and like tht but it wont <removed by moderator> move , And it doesnt have to be attached to The Web Browser , Just help me how to get it moving please?
    Last edited by si_the_geek; Aug 20th, 2008 at 03:50 PM.

  2. #2
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: How Does Progress Bar Work?

    to move it you need to increase its value ....ProgressBar1.Value = ProgressBar1.Value + 1

    but you need to have proper value to increase the value..for example if you are executing a set of statements to load a page, after each statement you can increment the value and set the max property of the progress bar to 10 for example.
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: How Does Progress Bar Work?

    Please don't swear - it is not only against our rules, but it also annoys people (which means they are less likely to help you).

    You can find an explanation of how to use a ProgressBar in the "Controls" section of our Classic VB FAQs (in the FAQ forum, which is shown near the top of our home page)

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Aug 2008
    Posts
    19

    Re: How Does Progress Bar Work?

    Quote Originally Posted by ganeshmoorthy
    to move it you need to increase its value ....ProgressBar1.Value = ProgressBar1.Value + 1

    but you need to have proper value to increase the value..for example if you are executing a set of statements to load a page, after each statement you can increment the value and set the max property of the progress bar to 10 for example.
    Yh thnx but now it moves one dot , i want it to move to full slowly , do i have to use a timer or summin? , and if so how does tht work?

  5. #5
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: How Does Progress Bar Work?

    Well yes, if you just do ProgressBar1.Value = ProgressBar1.Value + 1 it will move just one dot, but how you get it to move more depends on what you want it to represent. A simple loop like the following
    will move it very quickly but you probably want to have some process of yours to run in that loop.

    Code:
    Dim lngIndex As Long
    
    For lngIndex = 1 to 100
        ProgressBar1.Value = ProgressBar1.Value + lngIndex 
    Next

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Aug 2008
    Posts
    19

    Re: How Does Progress Bar Work?

    Private Sub Form_Load()
    Dim lngIndex As Long
    For lngIndex = 1 To 100
    ProgressBar1.Value = lngIndex
    Next
    WebBrowser1.Navigate "http://GamerZ.gnu.nu"
    End Sub

    Now im using tht and shure it works but how do i get it too move slower?

  7. #7
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: How Does Progress Bar Work?

    A progress bar is used to indicate progress in a process or series of processes where there are benchmarks of some sort that can be counted. Here's an example from a program of mine where I'm gathering information about picture and video files in a folder on my PC. pbThumbnails is the progressbar. Note that I set the Max of the progreebar toi the number of files and everytime I "read" one of the files I advance the progressbar by one.

    Code:
        intMax = FSO.GetFolder(tvwFolders.SelectedItem.Key).Files.Count
        Set FSO = Nothing
        pbThumbnails.Max = intMax
    
        Do While Len(strFile)
            If UCase$(Right$(strFile, 4)) = ".JPG" Or _
               UCase$(Right$(strFile, 4)) = ".MPG" Or _
               UCase$(Right$(strFile, 4)) = ".AVI" Then
                Set oPicture = New cPicture
                oPicture.PicName = tvwFolders.SelectedItem.Key & "\" & strFile
                lngIndex = lngIndex + 1 ' didn't actually need this before
                gJPEGS.AddPicture oPicture
                pbThumbnails.Value = lngIndex
                DoEvents
            End If
            strFile = Dir$
        Loop

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Aug 2008
    Posts
    19

    Re: How Does Progress Bar Work?

    Quote Originally Posted by MartinLiss
    A progress bar is used to indicate progress in a process or series of processes where there are benchmarks of some sort that can be counted. Here's an example from a program of mine where I'm gathering information about picture and video files in a folder on my PC. pbThumbnails is the progressbar. Note that I set the Max of the progreebar toi the number of files and everytime I "read" one of the files I advance the progressbar by one.

    Code:
        intMax = FSO.GetFolder(tvwFolders.SelectedItem.Key).Files.Count
        Set FSO = Nothing
        pbThumbnails.Max = intMax
    
        Do While Len(strFile)
            If UCase$(Right$(strFile, 4)) = ".JPG" Or _
               UCase$(Right$(strFile, 4)) = ".MPG" Or _
               UCase$(Right$(strFile, 4)) = ".AVI" Then
                Set oPicture = New cPicture
                oPicture.PicName = tvwFolders.SelectedItem.Key & "\" & strFile
                lngIndex = lngIndex + 1 ' didn't actually need this before
                gJPEGS.AddPicture oPicture
                pbThumbnails.Value = lngIndex
                DoEvents
            End If
            strFile = Dir$
        Loop
    Okay well , i dont really get it , but the thing i want is a progress bar to the web explorer im doing , so how do i just slow it down with a timer or summin , and how do i start the timer`?

  9. #9
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: How Does Progress Bar Work?

    Slowing it down wont do any good - for a progressbar to be any use, it needs to be directly related to a particular process (in your case, downloading a page).

    If you don't do that, you can easily get to 100% progress before the page has loaded, or only get to 5% before it has loaded. As you had the code it was even worse, as you were guaranteed to get to 100% before you even attempt to load the page.

    The article I referred you to explains all of that, and gives alternative methods that you could use instead of a ProgressBar.


    I wouldn't be surprised if there is something built in to the WebBrowser to show a ProgressBar (see the Properties window for it), and/or an event which tells you how much progress has been made so far - select "Webbrowser1" in the dropdown list at the top-left of the code window, and see what options are shown in the dropdown list at the top-right.

  10. #10
    Fanatic Member
    Join Date
    Feb 2001
    Posts
    759

    Re: How Does Progress Bar Work?


  11. #11

    Thread Starter
    Junior Member
    Join Date
    Aug 2008
    Posts
    19

    Re: How Does Progress Bar Work?

    Well i succeded , first i use some timers and in the las timer i use ,
    Code:
    if WebBrowser1.Busy = 1 Then
    ......
    Else
    ......
    End If
    Works really good now

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