I want to populate my msflexgrid with lots of data from a database and it takes seconds for the process to complete. In that case, i need to include a progress bar that shows the progress of the process above and i do not know the code that will simultaneously show the progress on a progress bar.
I appreciate your contributions in advance. Thank you.

Recommended Answers

All 5 Replies

For this first add a ProgressBar to your form.It is easy to increase the value of the progress bar.Just add another value.

I made an example.Here is the code to increase the Progress Bar.

Private Sub Form_Load()
Timer1.Interval = 1
ProgressBar1.Max = 1000
End Sub

Private Sub Timer1_Timer()
If ProgressBar1.Value = 1000 Then
Timer1.Enabled = False
Else
ProgressBar1.Value = ProgressBar1.Value + 1
End If
End Sub

Here you can set the maximum value of the Progress[above i set it to 1000].For you ; you can set the maximum value as required.It must be the total quantity of the data.
When one data is added just add this line
ProgressBar1.Value = ProgressBar1.Value + 1.
Don't forget to check the total value of progress bar.If it reaches the maximum you must stop it.
Try it .....

If you are using an object, i.e. ADO and a Do While Loop you could do something like...

Dim Cnt As Integer
adoRs.MoveLast
Prog1.Max = adoRs.RecordCount
adoRs.MoveFirst
Do While Not adoRs.EOF
  'populate grid...
  Cnt = Cnt + 1
  Prog1.Value = Cnt
  adoRs.MoveNext
Loop

Good Luck

dont forgot use doevents to show u response

That was helpful. Thanks to you guys.

For this first add a ProgressBar to your form.It is easy to increase the value of the progress bar.Just add another value.

I made an example.Here is the code to increase the Progress Bar.

Private Sub Form_Load()
Timer1.Interval = 1
ProgressBar1.Max = 1000
End Sub

Private Sub Timer1_Timer()
If ProgressBar1.Value = 1000 Then
Timer1.Enabled = False
Else
ProgressBar1.Value = ProgressBar1.Value + 1
End If
End Sub

Here you can set the maximum value of the Progress[above i set it to 1000].For you ; you can set the maximum value as required.It must be the total quantity of the data.
When one data is added just add this line
ProgressBar1.Value = ProgressBar1.Value + 1.
Don't forget to check the total value of progress bar.If it reaches the maximum you must stop it.
Try it .....

for 1/2 of this code can be done in properties box...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.