lidds Posted November 23, 2004 Posted November 23, 2004 Is there a way in vb.net that you can tell what mouse button was clicked (i.e. left mouse button) and then perform an operation. example: if left mouse button clicked then msgbox("left clicked") elseif right mouse button clicked then msgbox("right clicked") endif Thanks Simon Quote
Rick_Fla Posted November 23, 2004 Posted November 23, 2004 Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown If e.Button = MouseButtons.Right Then messagebox.show("Right Click") Else messagebox.show("Left Click") End If End Sub Quote "Nobody knows what I do until I stop doing it."
Rick_Fla Posted November 23, 2004 Posted November 23, 2004 Not a problem! Quote "Nobody knows what I do until I stop doing it."
Getox Posted November 27, 2004 Posted November 27, 2004 how would you do that for all the kayboard keys? Quote Page Edit 2.0 Alpha 2 OUT NOW! - Download Now -
coldfusion244 Posted November 27, 2004 Posted November 27, 2004 how would you do that for all the kayboard keys? In a different control, or on the form itself again? Quote -Sean
Getox Posted November 27, 2004 Posted November 27, 2004 form itself so if A is pressed i want the form to +1 in a textbox so if u press 3 diff chars the textbox will have the number 3 in it..you know what i mean? Quote Page Edit 2.0 Alpha 2 OUT NOW! - Download Now -
coldfusion244 Posted November 27, 2004 Posted November 27, 2004 I code in C++/C# , but I believe this should work. Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress If e.KeyChar = Chr(Keys.A) Then textbox1.Text = Integer.Parse(textbox1.text) + 1 End If End Sub If you wanted it for all keys then: Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress textbox1.Text = Integer.Parse(textbox1.text) + 1 End Sub Hope this helps. -Sean Quote -Sean
Getox Posted November 29, 2004 Posted November 29, 2004 I code in C++/C# , but I believe this should work. Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress If e.KeyChar = Chr(Keys.A) Then textbox1.Text = Integer.Parse(textbox1.text) + 1 End If End Sub If you wanted it for all keys then: Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress textbox1.Text = Integer.Parse(textbox1.text) + 1 End Sub Hope this helps. -Sean Thanks for the help but none worked..i tried changing a few things but still didnt work. i think its something in Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress Quote Page Edit 2.0 Alpha 2 OUT NOW! - Download Now -
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.