Paul,
There may be better ways of doing this but the following seems to work...
'------------------------------------
Private Sub TextBox1_Change()
If Val(TextBox1.Value) = 0 Then
TextBox1.Value = vbNullString
ElseIf Len(TextBox1.Value) 1 Then
If Val(TextBox1.Value) 11 Then TextBox1.Value = Left$(TextBox1.Value, 1)
End If
End Sub
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Dim strChar As String
strChar = Chr$(KeyAscii)
If strChar Like "[!0-9]" Then KeyAscii = 0
End Sub
'------------------------------------
Regards,
Jim Cone
San Francisco, CA
"Paul W Smith" wrote in message ...
I want to restrict the entries that are allowed in a text box to just the
numbers 1 to 11.
I have fiddled around with the KeyDown, KeyUp, and KeyPress events, only
allowing entries with ASCII codes between 48 and 56.
However I cannot get it right. Can any expert VB programmers please supply
the necessary code.
Paul Smith