progressbar.txt

来自「一部分关于VB编程的小技巧」· 文本 代码 · 共 23 行

TXT
23
字号
'Use with a picturebox
'Forecolor of picturebox = the progress color
'
'
Public Function UpdateProgress(pb As Control, ByVal Percent As Integer, Optional ByVal ShowPercent = False)
    On Error Resume Next
    Dim Num As String
    If Not pb.AutoRedraw Then
    pb.AutoRedraw = -1
    End If
pb.Cls
pb.ScaleWidth = 100

If ShowPercent = True Then
    Num$ = Format$(Percent, "###0") + "%"
    pb.CurrentX = 50 - pb.TextWidth(Num$) / 2
    pb.CurrentY = (pb.ScaleHeight - pb.TextHeight(Num$)) / 2
    pb.Print Num$ 'print percent
End If

pb.Line (0, 0)-(Percent, pb.ScaleHeight), , BF
pb.Refresh 'show differents
End Function

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?