2024年4月4日发(作者:)
VB编写进度条已经发展很久了,也有很多好方法。
VB自带的进度条很难看,一般不用,要用的话,
代码如下:
Private Sub Command1_Click()
Dim counter As Integer
Dim workarea(25000) As String
= LBound(workarea)
= UBound(workarea)
e = True
=
For counter = LBound(workarea) To
UBound(workarea)
workarea(counter) = "initial value" & counter
= counter
Next counter
End Sub
各位看官,直接看下面:
Option Explicit
Dim i As Integer
Private Sub Form_Load()
=
= ( / 100)
End Sub
Private Sub Timer1_Timer()
'进度条设置
= + ( / 100)
If ( / ) > 1 Then
'载入主画面
Unload Me
End If
End Sub
那么更换N个image就会有N个进度条演示,下
面示图,大家自己试试。
Text实现进度条:
Option Explicit
Dim i As Integer
Private Sub Form_Load()
d = True
= ( / 100)
End Sub
Private Sub Timer1_Timer()
'进度条设置
= + ( / 100)
If ( / ) > 1 Then
'载入主画面
Unload Me
End If
End Sub
Image进度条:
1/12
i = 0
End Sub
这样两个配合,进度条加进度百分比,看客们该是
熟悉了吧?具体时间和进度协调要看你的计算了。
Picture进度条:
'例子需以下控件: 'Command1、Command2、
Picture1:都采用默认属性设置
Dim ctEsc As Boolean
Private Sub Form_Load()
'初始化控件
draw = True
n = "滚动条例子":
n = "取消"
End Sub
Private Sub Command1_Click()
Dim I As Long, S As Long
ctEsc = False
S = 1000
For I = 1 To S
: "显示:" & I
JinDuTiao I / S, "0.0" '显示进度条:进度,显示
格式(即小数数位)
DoEvents
If ctEsc Then "已取消": Exit Sub
Next
"完毕"
End Sub
Private Sub Command2_Click()
ctEsc = True
End Sub
Private Sub JinDuTiao(Bi As Single, Optional
nFormt As String = "0")
Dim W As Long, H As Long, nStr As String
Static UpBi As String
nStr = Format(Bi * 100, nFormt)
If Val(nStr) >= "100" Then nStr = 100
If UpBi = nStr Then Exit Sub
UpBi = nStr
W = idth: H =
2/12
有看官马上问:那怎么显示百分比呢
这个不难,百分比代码:
'加一个timer和一个label
'From:
'Author:Minghacker
Dim b As Boolean
Dim i As Integer
Private Sub Timer1_Timer()
If b Then i = i + 1
If Not b Then i = i - 1
If i > 100 Then i = 100: b = False
If i < 0 Then i = 0: b = True
n = CStr(i) + " %"
End Sub
Private Sub Form_Load()
b = True
发布评论