TextBoxes and Button Shortcuts

  • Thread starter Thread starter Jason Hunt
  • Start date Start date
J

Jason Hunt

Hello All,

I have a form with some text boxes and buttons. The buttons have shortcuts
in their text labels, such as "&Add". When the user is still focused on the
textbox and presses Alt-A, does that Alt-A code get included with the text
value? It appears to be doing so, and I'm wondering what the best way to
deal with it is?

Each of the text boxes have a _Validating() function something like this:

If IsNumeric(Me.TextBox1.Text) Then
' Validate the text
Else
MsgBox("Invalid Entry")
Me.TextBox1.Focus()
End If

The IsNumeric() is failing, so I can only conclude that Alt-A is being added
to the .Text variable. Is there a way to stop this from happening, or strip
that Alt- code off the end?

Thanks.

- Jason
 
Hi Jason,

I played the scenario that you mentioned and did not face that problem. I
am puzzled as to why it is not working for you.

I have noticed one thing w/ the buttons w/ the shortcut. The shortcut does
not become visible unless you activate it. By this I mean that your "Add"
button does not look like "_Add" till you press "Alt-A" at least once.

Anyways, I am pasting my code below.

\\\
Private Sub button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles button1.Click
Dim txt As String
txt = TextBox1.Text
MsgBox(txt)
'Me.Close()

End Sub

Private Sub TextBox1_Validating(ByVal sender As System.Object, ByVal
e As System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating
If IsNumeric(Me.TextBox1.Text) Then
' Validate the text
Else
MsgBox("Invalid Entry")
Me.TextBox1.Focus()
e.Cancel = True
End If

End Sub

\\\

Whenever I press "Alt-C"; the button's shortcut, with the cursor in the
textbox the Messagebox displays the textbox data. I do not get the "invalid
entry" message unless the textbox has alphabets.

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top