Simulated KeyPressed

Myers75602

New member
Joined
May 30, 2006
Messages
2
Programming Experience
Beginner
I have a textbox that handles user input. In order to trap for only a full value (signified by the user pressing enter), I have done:

PrivateSub TextBox1_KeyPress(ByVal sender AsObject, ByVal e As _System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress

If e.KeyChar = vbCr Then
...
EndIf
EndSub


That works!

I also allow the user to click a TextBox2 and a value should automatically be filled into the textbox followed by a simulated keypress {ENTER}. I can change TextBox1.Text = "25" but then I have to:

Call TextBox1_KeyPress(TextBox2, vbCr)


-The vbCr part is not working.


I used to be able (in VB6) to:


TextBox1.Text = "25"
Call
TextBox1_KeyPress(13)


This is my very first project in VB.net so go easy on me! Is there a better way to do this?

-Myers-
 
Last edited:
instead of calling the keypress event of the 2nd textbox, just stick the new characters to the exists text property:

Textbox1.Text = "25"
Textbox1.Text &= Keys.Enter.ToString
 
SendKeys?

Unfortunately this just populates my text box with "25Enter".

It's closer but I need to have the Enter as a SendKeys or something??


JuggaloBrotha said:
instead of calling the keypress event of the 2nd textbox, just stick the new characters to the exists text property:

Textbox1.Text = "25"
Textbox1.Text &= Keys.Enter.ToString
 

Attachments

  • untitled.JPG
    untitled.JPG
    29.2 KB · Views: 51
Back
Top