PDA

Click to See Complete Forum and Search --> : Progress Bar


JonnyCab
Sep 12th, 2000, 08:58 PM
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

Dim
Sep 12th, 2000, 11:26 PM
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.

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

JonnyCab
Sep 13th, 2000, 06:28 AM
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

Sep 13th, 2000, 06:50 AM
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

Sep 13th, 2000, 07:32 AM
Excuse my typing I mentioned a progressbar and not a statusbar.


Can U 4 give me . . .

JonnyCab
Sep 13th, 2000, 07:48 AM
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?