vb中的鼠标单击事件
1:编写窗体的Load事件过程。要求把3个标签的Caption属性分别设置成“左键单击次数”“右键单击次数”“单击鼠标次数”,把三个文本框的Text属性内晴空。把框架的C...
1:编写窗体的Load事件过程。要求把3个标签的Caption属性分别设置成“左键单击次数”“右键单击次数”“单击鼠标次数”,把三个文本框的Text属性内晴空。把框架的Caption属性设置成“鼠标单击测试区域”,BackColor属性设置成白色。
展开
1个回答
展开全部
在窗体上放一个框架控件,3个标签控件,3个文本框控件,最好将3个文本框和3个标签放在框架外面,每个标签对应一个文本框,那么代码如下了
Private Sub Form_Load()
Frame1.Caption = "鼠标单击测试区域"
Label1.Caption = "左键单击次数"
Label2.Caption = "右键单击次数"
Label3.Caption = "单击鼠标次数"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Frame1.BackColor = &HFFFFFF
End Sub
Private Sub Frame1_Click()
Static n As Integer
n = n + 1
Text3.Text = n
End Sub
Private Sub Frame1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Select Case Button
Case 1
Static a As Integer
a = a + 1
Text1.Text = a
Case 2
Static b As Integer
b = b + 1
Text2.Text = b
End Select
End Sub
Private Sub Form_Load()
Frame1.Caption = "鼠标单击测试区域"
Label1.Caption = "左键单击次数"
Label2.Caption = "右键单击次数"
Label3.Caption = "单击鼠标次数"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Frame1.BackColor = &HFFFFFF
End Sub
Private Sub Frame1_Click()
Static n As Integer
n = n + 1
Text3.Text = n
End Sub
Private Sub Frame1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Select Case Button
Case 1
Static a As Integer
a = a + 1
Text1.Text = a
Case 2
Static b As Integer
b = b + 1
Text2.Text = b
End Select
End Sub
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询