在VB中,如何应用定时器和标签控件,编写一个文字在窗口上下移动的程序
来源:百度知道 编辑:UC知道 时间:2024/05/17 01:40:35
VB源代码使用Label控件和一个定时器便可实现
这个是随机移动的:
Dim oldH As Long
Dim oldW As Long
Private Sub Form_Load()
Label1.Caption = "VB真好玩!"
Timer1.Interval = 1000
oldH = Form1.Height - Label1.Height
oldW = Form1.Width - Label1.Width
End Sub
Private Sub Timer1_Timer()
Randomize
Label1.Left = Int(Rnd() * (oldW + 1))
Randomize
Label1.Top = Int(Rnd() * (oldH + 1))
End Sub