Question Some keyboard event does not work during program execution.

reyphillip

Member
Joined
Jul 27, 2010
Messages
12
Programming Experience
Beginner
Hi everyone!. I have a problem regarding in my program in which I have tried to deploy it but when I press enter or a keyboard event it does not perform it.. What seems to be the problem for this?:confused: Please help. Thanks.
 
Unfortunately that is far too little information for us make even an educated guess. Please provide a FULL and CLEAR description of EXACTLY what the expected behaviour is and what you did to produce the unexpected behaviour. Then we might at least have an idea of where you can look more closely for a potential cause.

Also, does the unexpected behaviour occur on more than one machine?
 
Here is my code for the Textbox3_KeyPress:

Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress
e.Handled = TrapKey(Asc(e.KeyChar))

Dim i As Integer
i = Convert.ToInt32(e.KeyChar())

If (i >= 48 And i <= 57) Or (i = 8) Then
Exit Sub
ElseIf (i = 13) Then
If Len(TextBox3.Text) = TextBox3.MaxLength Then
Try
TextBox4.Enabled = True
LinkLabel2.Enabled = True
TextBox4.Focus()
Catch

End Try
End If
End If
End Sub

I would like to focus the cursor in textbox4, It works in my computer but it doesn't work at all in other computers. Yup, I tried it to more than one machine to know if the problem was only on that machine where my program will be deployed but it doesn't work to all of them. I'm trying to recode it using the Keydown event I hope that this one's gonna work. But I'm still hoping you can help me with this one. THanks.
 
First up, you seem to have missed this part of my previous post:
Please provide a FULL and CLEAR description of EXACTLY what the expected behaviour is
Posting your code is NOT a full and clear description.

Apart from that, I can see one extremely bad aspect to that code right off the bat. It may or may not be related to this issue but look at this:
VB.NET:
Try
TextBox4.Enabled = True
LinkLabel2.Enabled = True
TextBox4.Focus()
[COLOR="Red"]Catch

End Try[/COLOR]
You have an exception handler there that does nothing at all. If an exception is thrown then you won't be notified in any way at all. The code just won't work. Does that sound anything like what's actually happening? Why do you have a Try...Catch block there in the first place? What are you expecting to go wrong? If there is something specific then you should handling that specifically. If there is nothing you expect then you shouldn't have a Try...Catch block there at all. If you are going to handle exceptions then you should be logging them somehow so that you know exactly what's occurring and can then fix it.

Also, as the documentation says, you should be calling Select or setting ActiveControl, not calling Focus, to make a control active.
 
Okay, I thought that posting my code would be clear enough, :D. First, the user will choose between the 3 choices using a radiobutton. After choosing, the cursor will select the Textbox3. Then by supplying the correct digits in textbox3 it is expected that Textbox4 will be enabled because I set it into Disabled as default. And then, It will select the Textbox4 if the digits are correct after that the user will supply again it's ID Number and by pressing ENTER in the keyboard the program will get all the details of the user and display it on a Listview. And then, I also have buttons in which the user will select which transaction it wants and perform it.

Yeah, I should just delete the Try Catch Block in my program. I modified my program already and change the focus() into select(). I don't know how to set ActiveControl yet, I'm still working on that.

The behaviour is that, just to enable and select the texbox4 in order to input the ID Number of the user. But it doesn't work. :D
 
Back
Top