Results 1 to 2 of 2

Thread: Progressbar apperars so much late in visual basic Activex...!

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2007
    Posts
    1

    Progressbar apperars so much late in visual basic Activex...!

    Hi,
    I made an activex (with visual basic 6.0), that downloads a file to client..I converted cab file with package&deployment wizard, and signed it..
    There is an progressbar on the usercontrol(activex control form)..
    and set the progressbar value appropriate value while downloading..
    I use these lines:
    VB Code:
    1. Do
    2.     DoEvents
    3.     bData = InetDwn.GetChunk(CHUNK, icByteArray)
    4.     DoEvents
    5.     If i Mod (downloading_file_all_size / 10) = 0 Then
    6.         ' I used this line to increase progressbar value every 10 percent
    7.         'downloaded
    8.         DoEvents
    9.         DoEvents
    10.         ProgressBar1.Value = ProgressBar1.Value + 1
    11.         DoEvents
    12.         DoEvents
    13.         i = 0
    14.         DoEvents
    15.         DoEvents
    16.     End If
    17.     DoEvents
    18.     DoEvents
    19.     Put #intfile, , bData
    20.     i = i + 1
    21. Loop While UBound(bData, 1) > 0
    but progressbar is appeared after all downloading and show %100....
    (I wrote "DoEvents" much, to progressbar works properly, But this does not help..)
    How can I solve this problem..?

    Please HELP....
    Last edited by Hack; Feb 2nd, 2007 at 08:02 AM. Reason: Added [vbcode] [/vbcode] tags and indenting

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: Progressbar apperars so much late in visual basic Activex...!

    DoEvents slows your program down each time it's encountered:
    VB Code:
    1. Do
    2.     bData = InetDwn.GetChunk(CHUNK, icByteArray)
    3.     If i Mod (downloading_file_all_size / 10) = 0 Then
    4.         ' I used this line to increase progressbar value every 10 percent downloaded
    5.         ProgressBar1.Value = ProgressBar1.Value + 1
    6.         DoEvents
    7.         i = 0 'what is this for?
    8.     End If
    9.     Put #intfile, , bData
    10.     i = i + 1
    11. Loop While UBound(bData, 1) > 0
    How many chunks are you downloading? You have to download at least 11 chunks for the progressbar to show more than 1 change.

    What is the maximum value of the progressbar? If you leave it at the default of 100, each increment will move it by 1%, so unless you have 100 chunks, you won't really get what you want. If you determine the number of chunks first, and set the .Max to that number, you'll get 10 jumps in the progressbar. If you just increment it after every chunk you'll get 100 jumps, so it'll look a lot smoother. (Downloading takes a LOT longer than changing the progressbar, so it won't slow your downloading.)
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

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