| |
A bi mi kdo razložil progressbar v visual basic 6
|
| |
| |
Koda:
Dim MyConn As New ADODB.Connection
Dim Sql As String
Dim MyRs As New Recordset
Private Sub AdjustListBoxSize()
' Some math, to show up and hide the percent and other label
' The listbox ovelaps the labels
If lstResults.Height = 3375 Then
lstResults.Height = 2790
lstResults.Top = 1800
Else
lstResults.Height = 3375
lstResults.Top = 1200
End If
End Sub
Private Sub cmdSearch_Click()
' Specify the SQL to be run on recordset - selecting all records
MyRs.Source = "Select * from Customers"
' Open the recordset (obtained from SQL)
MyRs.Open
Call AdjustListBoxSize
' Set up the progress bar's properties
ProgressBar1.Min = 0
ProgressBar1.Max = MyRs.RecordCount
ProgressBar1.Value = 0
' Set up the labels showing percentage of completion
lblPercent.Visible = True
Label2.Visible = True
' Clear the list box
lstResults.Clear
While Not MyRs.EOF
If MyRs("Country") = txtCountry.Text Then
lstResults.AddItem MyRs("CompanyName")
End If
lstResults.Refresh
For I = 0 To 400000
' 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
MyRs.MoveNext
Wend
' Hide the percent and other labels
lblPercent.Visible = False
Label2.Visible = False
Call AdjustListBoxSize
' Close the recordset object, so that the next query can be fired
MyRs.Close
End Sub
Private Sub Form_Load()
MyConn.Open "DSN=fpnwnd"
MyRs.ActiveConnection = MyConn
MyRs.CursorLocation = adUseClient
End Sub
Še link za več podatkov: http://www.codeguru.com/vb/controls/vb_a....
Drugače pa išči na Googlu: progress bar in visual basic
Lp,
aleksy
|
| |
| |
aleksy, ta koda je pa čisto OUT. To je še za povezavo z ADODB bazo.
ProgressBar je en kontrolnik, s katerim lahko prikazuješ neko stanje (to je tisti tekoči zeleni trak, ki se pojavi med inštalacijo ...). Temu kontrolniku določiš Value in pa Maximum. Value je trenutna vrednost, Maximum pa največja vrednost.
|
| |
| |
Bi se dalo narest, tako, da bi začel na 0 (prazen) nato pa bi se recimo 10 sekund polnil, ko pa bi bil poln, pa bo se pojavilo sporočilo, ali pa bi se spremenil tekst v label?
|
| |
| |
Najlažje je tako, da med neko proceduro povečuješ value. Primer (psevdo):
Začetek procedure
odpri datoteko
progressbar -> 1
preberi podatke iz textboxa
progressbar -> 2
zapiši v datoteko
progressbar -> 3
zapri datoteko
progressbar -> 4
povečaj spremenljivko
progressbar -> 5
Konec procedure
Lahko pa narediš tudi tako
For i = 0 To 10
Me.ProgressBar1.Value = i
Application.DoEvents()
System.Threading.Thread.Sleep(100)
Application.DoEvents()
Next
|
| |
Prikazujem 1 od skupno 1 strani |
|