Results 1 to 8 of 8

Thread: Need help with ProgressBar

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Location
    Ca
    Posts
    124

    Need help with ProgressBar

    Hi All in VB land

    I'm trying to make my file copy work with a progress bar
    I’m trying to make my progress bar looks at the file size and progress at about the speed that it is copying. Is this possible? I’m not looking for anything fancy just for it too work.

    Thanks everyone

  2. #2
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Need help with ProgressBar

    well im not sure if this is waht you need, but here.
    VB Code:
    1. Dim vtData()  As Byte
    2. Dim FreeNr    As Integer
    3. Dim SizeDone  As Long
    4. Dim bDone     As Boolean
    5. Dim GetPerc   As Integer
    6.  
    7. FreeNr = FreeFile
    8.    
    9.     Open App.Path & "\yay.rar" For Binary Access Write As FreeNr 'file your copying or whatever
    10.                
    11.     'this shows the status in real time
    12.     'kinda fancy
    13.    
    14.                 Do While Not bDone
    15.                     vtData = Inet1.GetChunk(1024, icByteArray) ' Get next chunk.
    16.                    
    17.                     SizeDone = SizeDone + UBound(vtData)
    18.                    
    19.                     lblStatus.Caption = SizeDone \ 1024 & "kb" & "/" & m_FileSize \ 1024 & "kb"
    20.                    
    21.                     GetPerc = (SizeDone / m_FileSize) * 100
    22.                     If GetPerc > 100 Then GetPerc = 100
    23.                     If GetPerc < 0 Then GetPerc = 0
    24.                    
    25.                     Me.Caption = "AutoUpdater - " & GetPerc & "%"
    26.                                        
    27.                     Put #FreeNr, , vtData()           'chunk wegschrijven naar bestand
    28.                     If UBound(vtData) = -1 Then
    29.                         bDone = True  'Er zijn geen chunks meer, KLAAR DUS
    30.                     Else
    31.                         DoEvents      'Yield to other processes
    32.                     End If
    33.                 Loop
    34.                
    35.                 Close FreeNr
    use the getperc to find the progress..this is not my code

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Need help with ProgressBar

    Most programs that shows a file copy progress, like a setup program for example, updates the progress after each file has been copied. But if your files are so large that you want to show the progress while they are copied you need to write your own copy procedure. Read and write the file in chunks and update the progressbar accordingly.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Location
    Ca
    Posts
    124

    Re: Need help with ProgressBar

    Hey whats a vtdata??

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Need help with ProgressBar

    In the above code it's a byte array.
    VB Code:
    1. Dim vtData()  As Byte

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Location
    Ca
    Posts
    124

    Re: Need help with ProgressBar

    I get An error

    "Object required"

    vb Code vtData = Inet1.GetChunk(1024, icByteArray) ' Get next chunk.

  7. #7
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Need help with ProgressBar

    Well that code uses an inet control to read data from the Net. Is that what you're trying to do?

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Location
    Ca
    Posts
    124

    Re: Need help with ProgressBar

    No I just want to copy a file from my C drive to the floppy drive. It's just a G code text file.

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