Results 1 to 6 of 6

Thread: Progress Bar

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Posts
    70

    Cool

    I would like to have a progress bar that keeps the user informed on processing progress.

    eg importing data from text file & updating tables.

    I get the feeling there is a reference I need to include in VB6... has any one got any code or advice on this mater.

    Cheers

  2. #2
    Fanatic Member Dim's Avatar
    Join Date
    Jul 2000
    Posts
    620
    Simply place a StatusBar on to your form
    Project/Components/Microsoft Windows Common Controls
    and this beofre each event place text into the statusbar.
    eg.
    Code:
    Public Sub Command1_Click()
    StatusBar1.SimpleText = "Opening Text File"
    Open "C:\myfile.txt" For Output As #1
       Print #1, Text1.Text
    Close #1
    StatusBar1.SimpleText = "File Opened"
    End Sub
    Hope that helps,
    D!m
    Dim

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Posts
    70
    I'm wanting to use a Progress Bar rather than a status bar so the user can get an indication of how long the processing is likely to take eg percentage completed.
    The code I am using to import data is shown below... can I use a progress bar to show the percentage completion and if so how would I do this in code?

    Open Me!CommonDialog1.FileName For Input As #1
    DataEnvironment1.Connection1.Open
    adoRecordset.CursorLocation = adUseClient
    adoRecordset.Open "tblTemp", DataEnvironment1.Connection1, adOpenStatic, adLockOptimistic
    'Loop reads a line at a time
    Do While Not EOF(1)
    Line Input #1, strLine
    With adoRecordset
    .AddNew
    !Contract = Mid(strLine, 1, 6)
    !CostCode = Mid(strLine, 10, 6)
    !Resource = Mid(strLine, 20, 6)
    !WorkActivity = Mid(strLine, 30, 6)
    !EntryDate = Mid(strLine, 55, 10)
    !Hours = Mid(strLine, 81, 6)
    !Breakeven = Mid(strLine, 97, 10)
    !Sell = Mid(strLine, 107, 10)
    .Update

    End With
    Loop

    adoRecordset.Close
    Close #1

  4. #4
    Guest

    Lightbulb

    Place a status bar on your form.
    Set the visible property to false
    This control is located where D!M told U
    then when U want to keep the user up to date on the events
    Set the bar visible
    Set its .Max property to the times U run trough the loop
    Set its .Min property at 0
    Before U enter the loop set its .Value = 0
    In the loop change the value + 1

  5. #5
    Guest

    Red face

    Excuse my typing I mentioned a progressbar and not a statusbar.


    Can U 4 give me . . .

  6. #6

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Posts
    70
    OK Swatty, that seems to make sense... and there is an example in the MSDN help stuff.

    My only problem is I don't know how many lines of data I am importing (and number of loops carried out until loops have been completed). User will be importing data on a weekly basis so size of files will vary. Is there a quick way of counting the number of lines in a text file before importing data?


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