current position:Home>Write your own VB progress bar control
Write your own VB progress bar control
2022-04-29 20:30:31【sysdzw】
This article has participated in 「 New people's creation ceremony 」 Activities , Start the road of nuggets creation together .
Main program code :
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
Copy code
Control code :
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 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 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 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 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
Copy code
The following is the running status :
Download the whole project :GitHub - sysdzw/vbprocessbar: vb Progress bar control
copyright notice
author[sysdzw],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/04/202204292030296171.html
The sidebar is recommended
- Talking about nodejs server
- Node. js&lt; I & gt—— Encounter node and repl usage
- Vue basic API: calculation attribute + filter + listener
- 1-stm32 + mn316 (nb-iot) remote upgrade OTA (self built Internet of things platform) - STM32 uses HTTP to download program files and upgrade programs through mn316 (MCU program rotation check and update)
- Vue Axios response interception
- vue3 ref
- How does Vue transfer the data from the parent component to the child component intact?
- The back-end interface developed by springboot in idea and the Vue front-end developed by vscode. How to integrate Vue code into springboot?
- Fried cold rice series 4: scope and closure in JavaScript
- Typescript type compatibility learning
guess what you like
Summary of bugs encountered in front-end development
Chrome developer tool: performance analysis using web panel
Collation of common semantic elements and global attributes in HTML
Life cycle in Vue
5.1 fear of traffic jam? With a budget of less than 100000, these cars with adaptive cruise make it easy for you to travel
Docker compose deploy nginx configure SSL
The content of element type “mapper“ must match “(cache-ref|cache|resultMap*|parameterMap*|sql*|inse
-CSS-
Vue uses two-way binding to implement the user registration page
Is Infiniti qx60 worth less than 400000 yuan? It depends on the discount
Random recommended
- "Element Fangjian: first heart version" public beta welfare release, go to the great God app to receive red envelopes and prizes
- What is the role of webpack cli in webpack packaging
- Vue3 configuration method using Axios
- How to configure Google reverse proxy on nginx server
- Volume comparison between Vue and react
- What are the three ways to define components in react
- How to install and configure the blogging program Typecho on the nginx server
- How to configure load balancing for TCP in nginx server
- How to configure nginx server under Windows system
- How to configure AB to do stress testing for nginx server
- Analysis of location configuration in nginx server
- How to integrate Linux and redmine into the redmine system
- How to build the production environment of nginx + PHP with PHP FPM
- How to optimize the performance of nginx supporting SSL
- How to configure nginx server to prevent flood attack
- [Axios learning] basic use of Axios
- [Axios learning] Axios request mode, concurrent request, global configuration, instance and interceptor
- Use the virtual queue implemented by list to view the first element of the queue in Python without taking it out
- This dependency was not found and to install it, you can run: NPM install score JS
- Front end serial communication
- leedcode. 203 remove linked list elements
- Dialogue with Liu Dayong, information director of Jiuyang shares: key elements of enterprise digital intelligence transformation
- JQuery gets the method summary of parent element, child element and brother element
- Web Security: analysis of DOM XSS vulnerability source code of jquery
- The sales volume of Genesys in China is 283, less than 300, and the domestic sales volume is dismal
- This beast was blessed with skills to test drive the DHT version of Harvard beast
- Bootstrap and jQuery implement tree structure
- Fried cold rice series 5: recursion in JavaScript?
- 2022 open source summer | serverless devs accompany you to "become stronger"
- How to create a high-performance full screen red envelope rain
- Detailed process of spring boot free HTTPS project configuration!
- Create a simple vue3 project
- How to create a simple react project
- Vue custom text background
- Front end HTML
- leetcode:462. Minimum number of moves to make array elements equal II [sort + find the middle]
- City selection (provincial and urban cascade) plug-in v-distpicker component details and a full set of usage
- How to use js to achieve such a drag and zoom effect
- Quick report ~ node JS 18 coming! Let's see what's new
- Easily manage projects using Vue UI graphical interface