16. Write a program in VB to display the status of mouse using label controls program should display current x, y positions of mouse. When user clicks left or right buttons label should indicate which button is pressed. Program should also indicates double click .When user clicks on close, show summery report as given below


Dim cnt As Integer
Dim cnt1 As Integer
Dim cnt2 As Integer

Private Sub Command1_Click()
Form2.Show
Form2.Text1.Text = cnt
Form2.Text2.Text = cnt1
Form2.Text3.Text = cnt2
End Sub

Private Sub Form_DblClick()
cnt2 = cnt2 + 1
LblDblClick.Caption = cnt2
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
cnt = cnt + 1
LblLeftClick.Caption = cnt
End If
If Button = vbRightButton Then
cnt1 = cnt1 + 1
LblRightClick.Caption = cnt1
End If

End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim strpos As String
Dim xpos As Integer
Dim ypos As Integer

xpos = X
ypos = Y
strpos = “x : ” & xpos & ” y : ” & ypos
Label1.Caption = strpos
End Sub
Private Sub form_load()
cnt = 0
cnt1 = 0
End Sub

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s