Greetings

I have a USB RFID scanner. While I have this form1 up, I want to send any keyboard input and put it in a textbox which is in another form(say form2). I tried using this code but to no avail. The first form is named "MainMenu".
Every time of a keypress, the the letter or digit input will go to another form. Is this even possible or am I just doing something wrong?

Private Sub MainMenu_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress

    Form2.Textbox1.text = e.KeyChar

End Sub

You're on the right track. MainMenu can't have any control that will steal the focus. Setting Enabled property to false works. Also, setting all the tabstop properties to false will work.

You could try setting the forms KeyPreview property to True. You'll have to do some pre-processing in one of the form's Key events (KeyDown, KeyPress, KeyUp) to ensure the characters are handled properly.

I may be old-school, but I like global variables for things like this. I think what I'd do is something like:

[frm1] gblVar = ""
[frm2] @ KeyPress event: gblVar &= e.keychar
then, when frm2.close
txtFld.text = gblVar

@Reverend Jim

setting the form's KeyPreview property to True worked like a charm. Whatever input I give can go to the other form without using the textbox. Now I just need the device and work on how to make the reader read multiple tags at once, having different separate inputs.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.