在VB中,先设立一个Label,它的值设为3,但是它是隐藏的,我希望把鼠标移到Label上时,Label的值就会显现
把鼠标移开,label就会隐藏,并且要记录下Label显现出来的时间,也就是从鼠标放到label上和移开label的中间所经历的时间,精确到毫秒。请问应该如何编程?...
把鼠标移开,label就会隐藏,并且要记录下Label显现出来的时间,也就是从鼠标放到label上和移开label的中间所经历的时间,精确到毫秒。请问应该如何编程?
展开
2个回答
展开全部
窗体上添加2个标签,1个Timer
你那个Label1适当大一点?
代码如下:
Option Explicit
Private LL As String
Private n As Double
Private YesNo As Boolean
Private Sub Form_Load()
LL = "3"
Timer1.Interval = 1
Timer1.Enabled = False
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If YesNo Then
Label1.Caption = ""
Timer1.Enabled = False
Label2.Caption = "时间: " & n & " 毫秒"
YesNo = False
End If
End Sub
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Not YesNo Then
YesNo = True
n = 0
Timer1.Enabled = True
Label1.Caption = LL
End If
End Sub
Private Sub Timer1_Timer()
n = n + 1
End Sub
你那个Label1适当大一点?
代码如下:
Option Explicit
Private LL As String
Private n As Double
Private YesNo As Boolean
Private Sub Form_Load()
LL = "3"
Timer1.Interval = 1
Timer1.Enabled = False
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If YesNo Then
Label1.Caption = ""
Timer1.Enabled = False
Label2.Caption = "时间: " & n & " 毫秒"
YesNo = False
End If
End Sub
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Not YesNo Then
YesNo = True
n = 0
Timer1.Enabled = True
Label1.Caption = LL
End If
End Sub
Private Sub Timer1_Timer()
n = n + 1
End Sub
更多追问追答
追问
不错,可以运行,但貌似Timer精确度不高啊,感觉时间不准。该如何解决?谢谢!
追答
时间已经设置成每毫秒1次的频率,误差你自己想办法解决了。实在对不起。
我不知道你是如何判断毫秒精度的?
展开全部
显示隐藏可以用以下代码:
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.ForeColor = Form1.BackColor
End Sub
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.ForeColor = RGB(0, 0, 0)
End Sub
计时的话肯定要用tmer,你自己去研究以下吧
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.ForeColor = Form1.BackColor
End Sub
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.ForeColor = RGB(0, 0, 0)
End Sub
计时的话肯定要用tmer,你自己去研究以下吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询