Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

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


"Nobody knows what I do until I stop doing it."
Posted

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?

Page Edit 2.0 Alpha 2 OUT NOW!

- Download Now -

Posted

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

-Sean
Posted
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

Page Edit 2.0 Alpha 2 OUT NOW!

- Download Now -

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...