文档详情

VB编写进度条.doc

发布:2018-07-01约1.71万字共12页下载文档
文本预览下载声明
PAGE 1/ NUMPAGES 12VB编写进度条已经发展很久了,也有很多好方法。VB自带的进度条很难看,一般不用,要用的话,代码如下:Private Sub Command1_Click() Dim counter As Integer Dim workarea(25000) As String ProgressBar1.Min = LBound(workarea) ProgressBar1.Max = UBound(workarea) ProgressBar1.Visible = True ProgressBar1.Value = ProgressBar1.Min For counter = LBound(workarea) To UBound(workarea) workarea(counter) = initial value counter ProgressBar1.Value = counter Next counter End Sub各位看官,直接看下面:Text实现进度条:   Option Explicit Dim 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 Me End If End Sub Image进度条:Option Explicit Dim 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 Me End IfEnd Sub?那么更换N个image就会有N个进度条演示,下面示图,大家自己试试。有看官马上问:那怎么显示百分比呢这个不难,百分比代码:加一个timer和一个labelFrom:Author:MinghackerDim 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 Label1.Caption = CStr(i) + % End Sub Private Sub Form_Load() b = True i = 0 End 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
显示全部
相似文档