View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
TK TK is offline
external usenet poster
 
Posts: 177
Default Inputting numbers only in Text Box

Hi Anthony:

'This is also a way to test the input.

'/// Place the following on the Sheet

Private Sub CommandButton1_Click()
With UserForm1
.Show
.TextBox1.SelStart = 0
.TextBox1.SelLength = Len(.TextBox1.Text)
.TextBox1.SetFocus
End With
End Sub

'/// This is on the Userform

Private Sub CommandButton1_Click()

If IsNumeric(TextBox1.Text) Then
TextBox1.Text = TextBox1.Text
MsgBox "Your Number is " & TextBox1.Text, , _
"Good Luck TK"
UserForm1.Hide
Else
MsgBox "Please enter a valid Number "
With TextBox1
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End With
End If
Exit Sub
End Sub

'Good Luck
TK