R
rob nobel
With thanks to Harald who gave me this procedure which makes sure a number
is entered into a UserForm (and works great) .......
Q. Is there a way, that when the Enter key is hit, the userform accepts the
value entered without having to hit the Enter key twice?
Private Sub TextBox1_KeyPress(ByVal _
KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case 48 To 57
Case Else
KeyAscii = 0
End Select
End Sub
Private Sub TextBox1_KeyDown(ByVal _
KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
If Shift = 2 Then KeyCode = 0
End Sub
Private Sub OKButton_Click()
Dim tax As String
tax = TextBox1.Text
If tax = "" Then
MsgBox "You must enter a number (without $ sign.)."
Unload Me
ufTaxWithheld.Show
Exit Sub
End If
ActiveCell = TextBox1.Value
Unload Me
End Sub
is entered into a UserForm (and works great) .......
Q. Is there a way, that when the Enter key is hit, the userform accepts the
value entered without having to hit the Enter key twice?
Private Sub TextBox1_KeyPress(ByVal _
KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case 48 To 57
Case Else
KeyAscii = 0
End Select
End Sub
Private Sub TextBox1_KeyDown(ByVal _
KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
If Shift = 2 Then KeyCode = 0
End Sub
Private Sub OKButton_Click()
Dim tax As String
tax = TextBox1.Text
If tax = "" Then
MsgBox "You must enter a number (without $ sign.)."
Unload Me
ufTaxWithheld.Show
Exit Sub
End If
ActiveCell = TextBox1.Value
Unload Me
End Sub