Hello..!
i have an problem to connect a progress bar with listview object.P.bar working properly. bt i want to connect p.bar with ma sql database while m searching database.kindly help me where m i doin wrong..the code is below.

Private Sub cmdRFind1_Click()
On Error Resume Next

Dim vLst As ListItem

LstV1.ListItems.Clear

ProgressBar1.Min = 0
ProgressBar1.Max = d.RecordCount
ProgressBar1.Value = 0

If d.BOF = True Then Exit Sub
d.MoveFirst

While Not d.EOF

If d.Fields(0) = txtRWise.Text Then
'--------------- TEXT BOX ------------------------
'==================================================

Set vLst = LstV1.ListItems.Add(, , LstV1.ListItems.Count)
vLst.SubItems(1) = d.Fields(0) 'Voucher No
vLst.SubItems(2) = d.Fields(1) 'Date
vLst.SubItems(3) = d.Fields(2) 'GRNo
vLst.SubItems(4) = d.Fields(3) 'Year
vLst.SubItems(5) = d.Fields(4) 'Month1
vLst.SubItems(6) = d.Fields(5) 'Month2
vLst.SubItems(7) = d.Fields(6) 'Month3
'vLst.SubItems(8) = d.Fields(7)

'================================
' Fee Category
'================================
vLst.SubItems(9) = d.Fields(7)
vLst.SubItems(10) = d.Fields(8)
vLst.SubItems(11) = d.Fields(9)
vLst.SubItems(12) = d.Fields(10)
vLst.SubItems(13) = d.Fields(11)
vLst.SubItems(14) = d.Fields(12)
vLst.SubItems(15) = d.Fields(13)

LstV1.Refresh
End If
For I = 0 To d.RecordCount
' Do nothing, but wait
' To show up the progress bar proceeding
Next I

' Update the progress bar and percent label accordingly
ProgressBar1.Value = ProgressBar1.Value + 1
lblPercent.Caption = Int(ProgressBar1.Value * 100 / ProgressBar1.Max)
lblPercent.Refresh
d.MoveNext

Wend

LstV1.Refresh
Me.txtRWise.Text = ""


End Sub

Change your 'While' statement and 'Wend' to -

Do While d.EOF = False
'Polpulate Listview here
'Remove the following, unnecessary code
For I = 0 To d.RecordCount
' Do nothing, but wait
' To show up the progress bar proceeding
Next I

ProgressBar1.Value = ProgressBar1.Value + 1
lblPercent.Caption = Int(ProgressBar1.Value * 100 / ProgressBar1.Max)

d.MoveNext

Loop

This should show the progress, update the label and move on the next load of the listview.

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.