VB编写进度条.doc
文本预览下载声明
PAGE 1/ NUMPAGES 12VB编写进度条已经发展很久了,也有很多好方法。VB自带的进度条很难看,一般不用,要用的话,代码如下:Private Sub Command1_Click()Dim counter As IntegerDim workarea(25000) As StringProgressBar1.Min = LBound(workarea)ProgressBar1.Max = UBound(workarea)ProgressBar1.Visible = TrueProgressBar1.Value = ProgressBar1.MinFor counter = LBound(workarea) To UBound(workarea)workarea(counter) = initial value counterProgressBar1.Value = counterNext counterEnd Sub各位看官,直接看下面:Text实现进度条: Option ExplicitDim i As IntegerPrivate Sub Form_Load()Timer1.Enabled = True? Text2.Width = (Form1.Width / 100)End SubPrivate Sub Timer1_Timer()进度条设置Text2.Width = Text2.Width + (Form1.Width / 100)If (Text2.Width / Form1.Width) 1 Then? Form2.Show 载入主画面? Unload MeEnd IfEnd Sub Image进度条:Option ExplicitDim i As IntegerPrivate Sub Form_Load()?? ? JDT.Top = Lab.Top? JDT.Width = (Lab.Width / 100)End SubPrivate Sub Timer1_Timer()进度条设置JDT.Width = JDT.Width + (Lab.Width / 100)If (JDT.Width / Lab.Width) 1 Then? Form1.Show 载入主画面? Unload MeEnd IfEnd Sub?那么更换N个image就会有N个进度条演示,下面示图,大家自己试试。有看官马上问:那怎么显示百分比呢这个不难,百分比代码:加一个timer和一个labelFrom:Author:MinghackerDim b As BooleanDim i As IntegerPrivate Sub Timer1_Timer()If b Then i = i + 1If Not b Then i = i - 1If i 100 Then i = 100: b = FalseIf i 0 Then i = 0: b = TrueLabel1.Caption = CStr(i) + %End SubPrivate Sub Form_Load()b = Truei = 0End Sub这样两个配合,进度条加进度百分比,看客们该是熟悉了吧?具体时间和进度协调要看你的计算了。Picture进度条:例子需以下控件: Command1、Command2、Picture1:都采用默认属性设置 Dim ctEsc As Boolean Private Sub Form_Load() ????初始化控件 ?? Picture1.AutoRedraw = True ?? Command1.Caption = 滚动条例子: Command2.Caption = 取消 End Sub Private Sub Command1_Click() ?? Dim I As Long, S As Long ?? ?? ctEsc = False ?? S = 1000 ?? For I = 1 To S ??????Me.Cls: Me.Print 显示: I ??????JinDuTiao I / S, 0.0 显示进度条:进度,显示格式(即小数数位) ??????DoEvents ??????If ctEsc Then Me.Print 已取消: Exit Sub ?? Next ?? Me.Print 完毕 End Sub Private Sub Command2_Click() ?? ctEsc = True End Sub Private Sub JinDuTiao(Bi As
显示全部