how can i limit the textbox to input sysmbols and numbers

such as 1,2,3,4,.......;'/,[]=-.... and as such

pls help...

this following code to input string only, number and other symbols cannot input in texbox :

Private Sub Text1_KeyPress(KeyAscii As Integer)
  Select Case KeyAscii
   Case 65 To 90, 8
    'Let these key codes pass through
   Case 97 To 122, 8
    'Let these key codes pass through
   Case Else
    'All others get trapped
    KeyAscii = 0
 End Select
End Sub

i wanted to input only letters and not any other..pls help...

Sorry lerkei..
i modified my post cause the code above cannot input space, just a little code

Private Sub Text1_KeyPress(KeyAscii As Integer)
    Select Case KeyAscii
        Case 65 To 90, 8, 32
        'Let these key codes pass through
        Case 97 To 122, 8, 32
        'Let these key codes pass through
        Case Else
        'All others get trapped
        KeyAscii = 0
    End Select
End Sub

great....!!! thank you so much..=)

pls also help me in randomizing frames..

plsss...

another thing, can i place it in text1_change?

for i place a setfocus on the next textbox, but didn,t work....

no, cause the code handle key pressed.
if you want to handle by text change, you can use IsNumeric() function.
try this following code :

Private Sub Text1_Change()
    If IsNumeric(Right(Text1, 1)) = True Then
          Text1 = Left(Text1, Len(Text1) - 1)
     Else
     ' number
 
    End If
End Sub
This question has already been answered. Start a new discussion instead.