Code ทำ Progress Bar in Microsoft Access
Option Compare Database Option Explicit Dim holdPercComplete As Single Private Sub UpdateProgress(CurrentItem As Long, TotalItems As Long, taskName As String) Dim PercComplete As Single Dim intWidth As Integer Me.lblCurrentTask.Caption = taskName 'Validate data If CurrentItem <= 0 Or TotalItems <= 0 Then imgProgress.Width = 0 Exit Sub End If 'Calculate the percentage complete PercComplete = CurrentItem / TotalItems If Int(PercComplete * 100) = Int(holdPercComplete * 100) Then Exit Sub End If 'Save it for comparison holdPercComplete = PercComplete 'Calculate how wide to make the progress bar If (PercComplete * 100) Mod 5 = 0 Then intWidth = (BoxProgress.Width * PercComplete) imgProgress.Width = intWidth DoEvents 'or Me.Repaint End If End Sub Private Sub Form_Load() Call UpdateProgress(0, 0, "Idle") End Sub Private Sub cmdStart_Click() Dim lngItem As Long Const lngTotal As Long = 100000 Do While lngItem <= lngTotal lngItem = lngItem + 1 If lngItem < 50000 Then Call UpdateProgress(lngItem, lngTotal, "Starting...") ElseIf lngItem < 75000 Then Call UpdateProgress(lngItem, lngTotal, "Getting there...") Else Call UpdateProgress(lngItem, lngTotal, "Almost finished...") End If Loop Call UpdateProgress(lngItem, lngTotal, "Task complete") End Sub
Code ทำ Progress Bar in Microsoft Access
Reviewed by IOffer
on
ตุลาคม 26, 2559
Rating:
ไม่มีความคิดเห็น:
แสดงความคิดเห็น