|
进度条演示
Option Explicit
Sub CenterFrame()
fraProperties.Move _
(frmPrgBar.ScaleWidth / 2) - (fraProperties.Width / 2), _
(frmPrgBar.ScaleHeight / 2) - (fraProperties.Height / 2), _
fraProperties.Width, _
fraProperties.Height
End Sub
Private Sub cboAlign_Click()
' Set ProgressBar alignment
prgTestBar.Align = cboAlign.ListIndex
' If alignment is set to None, then just
' set its Width and Left properties to match
' those of the frame and offset it's top by
' 200 twips from the frames bottom.
If prgTestBar.Align = 0 Then
prgTestBar.Width = fraProperties.Width
prgTestBar.Left = fraProperties.Left
prgTestBar.TOP = fraProperties.TOP + fraProperties.Height + 200
End If
End Sub
Private Sub cmdExit_Click()
Unload frmPrgBar
End
End Sub
Private Sub cmdTestBar_Click()
Dim intBarValue As Integer
'Verify property settings
On Error GoTo ErrorHandler
'Set propeties and run test
prgTestBar.MIN = CInt(txtMin)
prgTestBar.MAX = CInt(txtMax)
For intBarValue = prgTestBar.MIN To prgTestBar.MAX
prgTestBar.VALUE = intBarValue
DoEvents
Next
'Reset Bar and exit
prgTestBar.VALUE = prgTestBar.MIN
Exit Sub
ErrorHandler:
Select Case Err.Number
Case Is = 13
MsgBox "Invalid property value", , App.ProductName
Case Is = 6
MsgBox "Property value too large", , App.ProductName
Case Else
MsgBox "Maximum value must be greater than Minimum value", ,
App.ProductName
End Select
Exit Sub
End Sub
Private Sub Form_Load()
CenterFrame
'Set default Min and Max Properties
txtMin = 0
txtMax = 100
'Set Alignment to Top
cboAlign.ListIndex = 1
End Sub
Private Sub Form_Resize()
CenterFrame
cboAlign_Click 'Realign Progress Bar
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set frmPrgBar = Nothing
End Sub
|