日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

自己编写vb进度条控件

發(fā)布時(shí)間:2023/12/14 编程问答 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 自己编写vb进度条控件 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

主程序代碼:

Option Explicit

Dim i As Double

Private Sub Command1_Click()
i = 0
Timer1.Interval = 50
Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
i = i + 0.05
ProcessBar1.Percent = i
If i > 1 Then Timer1.Enabled = False
End Sub

控件代碼:

Option Explicit

Public Enum FigureStyle
eOnlyValueInt
eOnlyValueDouble
ePercentInt
ePercentDouble
End Enum

Private dblMyPercent As Double
Private lngMyValue As Long
Private isShowMsg As Boolean
Private strMsg As String
Private intMsgStyle As FigureStyle

Private Max As Long, Min As Long

Private Sub UserControl_Initialize()
Min = 0
Max = 100
’ lngMyValue = 30
dblMyPercent = lngMyValue / (Max - Min)
lblValue.Caption = Int(dblMyPercent * 100) & “/100”
UserControl.Height = lblBase.Height
intMsgStyle = ePercentInt

Call setLabelSize

End Sub

Private Sub UserControl_Resize()
Call setLabelSize
End Sub

Private Sub setLabelSize()
lblBase.Move 0, 0, UserControl.ScaleWidth, UserControl.ScaleHeight
lblTop.Move lblBase.Left, lblBase.Top, dblMyPercent * lblBase.Width, lblBase.Height
lblValue.Move lblBase.Left, (lblBase.Height - lblValue.Height) / 2 + 20, lblBase.Width
End Sub
'set the value
Public Property Let Value(ByVal Value As Long)
If Value < Min Then
lngMyValue = Min
ElseIf Value > Max Then
lngMyValue = Max
Else
lngMyValue = Value
End If

dblMyPercent = lngMyValue / (Max - Min) lblTop.Width = dblMyPercent * lblBase.Width Select Case intMsgStyleCase eOnlyValueInt: strMsg = Int(dblMyPercent * 100)Case eOnlyValueDouble: strMsg = CStr(dblMyPercent * 100)Case ePercentInt: strMsg = Int(dblMyPercent * 100) & "/100"Case ePercentDouble: strMsg = CStr(dblMyPercent * 100) & "/100" End Select lblValue.Caption = strMsg

End Property

Public Property Get Value() As Long
Value = lngMyValue
End Property
'set the percent
Public Property Let Percent(ByVal Percent As Double)
If Percent < 0 Then
dblMyPercent = 0
ElseIf Percent > 1 Then
dblMyPercent = 1
Else
dblMyPercent = Percent
End If

lngMyValue = dblMyPercent * (Max - Min) lblTop.Width = dblMyPercent * lblBase.Width Select Case intMsgStyleCase eOnlyValueInt: strMsg = Int(dblMyPercent * 100)Case eOnlyValueDouble: strMsg = CStr(dblMyPercent * 100)Case ePercentInt: strMsg = Int(dblMyPercent * 100) & "/100"Case ePercentDouble: strMsg = CStr(dblMyPercent * 100) & "/100" End Select lblValue.Caption = strMsg

End Property

Public Property Get Percent() As Double
Percent = dblMyPercent
End Property
'is show msg
Public Property Let ShowMsg(ByVal ShowMsg As Boolean)
isShowMsg = ShowMsg
lblValue.Visible = isShowMsg
End Property

Public Property Get ShowMsg() As Boolean
ShowMsg = isShowMsg
End Property
'msg style
Public Property Let MsgStyle(ByVal MsgStyle As FigureStyle)
intMsgStyle = MsgStyle
Select Case intMsgStyle
Case eOnlyValueInt: strMsg = Int(dblMyPercent * 100)
Case eOnlyValueDouble: strMsg = CStr(dblMyPercent * 100)
Case ePercentInt: strMsg = Int(dblMyPercent * 100) & “/100”
Case ePercentDouble: strMsg = CStr(dblMyPercent * 100) & “/100”
End Select
lblValue.Caption = strMsg
End Property

Public Property Get MsgStyle() As FigureStyle
MsgStyle = intMsgStyle
End Property

以下為運(yùn)行狀態(tài):


整個(gè)工程下載:https://github.com/sysdzw/vbprocessbar

總結(jié)

以上是生活随笔為你收集整理的自己编写vb进度条控件的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。