嘉兴台展模具有限公司:VB中Timer控件的问题,盼望高手能抽空看看帮忙解决,谢谢!

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/28 00:20:34
怎样用Timer控件实现在窗体中一个标签的文本框内后面+".",但是不是一直加,而是加到4个点,又从头开始加.

eg:login窗体的Label1的文本框内容是:数据库加载中,用timer控件怎样实现Label数据库加载中这6个字后面+".",但是加到数据库加载中....的时候,又从头开始重复执行,代码怎么写了,我怎么弄都是一直加...盼望解决,最好能给个代码,谢谢!
还是不太明白.看我的程序.是不是还少什么啊
Private Sub Timer2_Timer()
Label3.Caption = Label3.Caption + "."
Dim max
max = 4
If max Mod 4 = 0 Then
max = 0
End If
End Sub

这样还是一直+.........

定义一个变量来记录“.”的显示数量,不能在Timer2中定义,在Form_Load中初始化。

Dim Number As Integer
Number=0
Label="数据库加载中"

Private Sub Timer2_timer()
If Number <= 6 Then
Label = Label & "."
Number = Number + 1
Else
Number=0
Label="数据库加载中"
End If
Edn Sub

以下代码每5秒重复一次,如要加快或减慢,则将代码第7和第15行取消,并修改Timer1控件的Interval属性值:
Option Explicit
Dim sum As Byte

Private Sub Form_Load()
Label2.Caption = "数据加载中"
End Sub

Private Sub Timer1_Timer()
If Label1.Caption <> CStr(Time$) Then
Label1.Caption = Time$
sum = sum + 1
Label2.Caption = Label2.Caption + "."
If sum >= 5 Then
sum = sum - 5
Label2.Caption = "数据加载中"
End If
End If
End Sub

在timer运行时将label.Caption="数据库加载中"

Private Sub Timer2_Timer()
if label.Caption<>"数据库加载中......"
label.Caption=label.Caption & "."
else
label.Caption="数据库加载中"
end if
End Sub

这样就好了!

dim max
max=4

if max mod 4 = 0 then
max = 0
end if