Results 1 to 14 of 14

Thread: Progress Bar

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2002
    Posts
    64

    Cool Progress Bar

    Hello,

    I am copying a file from one directory to another, I wan tthe progress bar to show be activated, for the end user knows that a processing thing is going on.

    How can I do this.
    progressbar.value = ??????
    In ordinary cases, where I can access the progress bar in a loop, I use this way.
    Is there any specific changes, or property I have to recognise?
    Thanks for your help.

  2. #2
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    Ever notice how on some programs the last part of the progress bar seems to fly by?

    Use a timer to add a value to the Progressbar.value property at an iterval of your liking...

    The max value of the progress bar needs to be reasonable, but far ahead of what time it would take to finish the task. At the end of the task set the value to 100.

    Easy cheesy, but it works.
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  3. #3
    Frenzied Member vbgladiator's Avatar
    Join Date
    May 2001
    Posts
    1,950
    I don't think you can do this with copying just one file. I mean how do you know how much copying has taken place and how much is left?

    With more than 1 file you can do it based on the file count.

  4. #4
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    The point is a reasonable visual interpretation. Say it would take 5 seconds to copy 5 megs on a 1 GIG machine. Create a function which can figure a factor based of the size of the data and the speed of the computer. As far as time, add 10 % to the returned number. See what I am getting at?
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  5. #5
    Frenzied Member vbgladiator's Avatar
    Join Date
    May 2001
    Posts
    1,950
    Oh, OK.

    So you have to predict.

  6. #6
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    -= a peet post =-

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Mar 2002
    Posts
    64

    Thumbs up Small Note

    Hello,
    Thanks for you all for the Ideas, but I want to add a samll details, I am using "FileCopy " methode.
    If this may advance the conversation.

  8. #8
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    when using filecopy, there is no way of knowing how far in the copy process u are.

    think u have to "fake" it, as they have suggested abow
    -= a peet post =-

  9. #9
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Mar 2002
    Posts
    64

    Thumbs down timer didn't work

    Hello

    I activated the timer before the copy process, but it didn't activate.
    I used the following codes.

    i =0
    timer.enable = true
    filecopy from, to
    timer.enable = false


    private sub timer_timer
    i = i+1
    progress_bar.value = i
    end sub

    So what do yuo suggest?

  11. #11
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    no u'r right... sorry didn't think of that...

    u won't get any processor time to do the update of the progress bar when the file is beeing copied.

    Did u try the sample in the link I posted earlier in this thread?

    could u use that?
    -= a peet post =-

  12. #12
    Lively Member
    Join Date
    Nov 2000
    Location
    Sugar Grove, IL
    Posts
    99
    A file doesn't just appear in the other directory right? I think that if you set the max value as the value of the LenB(yourFile) and you set a timer to fire off every .1 or .2 of a second, and looked at the size of file in the copy location and set the ProgressBar.Value = LenB(theFileInTheCopyLocation)? Haven't tested it, but it seems like it would work.
    In case of a water landing, my head may be used as a flotation device.

  13. #13
    Lively Member
    Join Date
    Nov 2000
    Location
    Sugar Grove, IL
    Posts
    99
    Ahhhhh, doesn't fire off asynchronous does it. Didn't think of that.
    In case of a water landing, my head may be used as a flotation device.

  14. #14
    Lively Member
    Join Date
    Nov 2000
    Location
    Sugar Grove, IL
    Posts
    99
    Because I don't like being defeated by myself.

    One way is to make a seperate, really tiny executable to do the copying for you.

    VB Code:
    1. Public Sub Form_Load()
    2.      'assume Command is sent with a * as a delimiter
    3.      filecopy Mid(Command, 1, InStr(Command, "*") -1), to Mid  (Command, InStr(Command, "*") + 1)
    4. End Sub

    Then in your code, Shell to the Executable, and start your timer

    VB Code:
    1. Public Sub CopyMe_Click()
    2.  
    3.      ProgressBar.Max = LenB(fileToCopy)
    4.      Shell("locationOfNewExecutable fileToCopy*newLocation", 6)
    5.      Timer.Enable = True
    6.  
    7. End Sub
    8.  
    9. Private Sub Timer_Timer()
    10.      ProgressBar.Value = LenB(newLocation)
    11.      If ProgressBar.Value = ProgressBar.Max Then: Timer.Enabled = False
    12. End Sub

    That'll work.
    In case of a water landing, my head may be used as a flotation device.

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