hi, I wanted to detect characters in a text box, except for numbers. I did that before using Chr$().. but now an error occurs and says "argument not optional"! Please if anyone could help me, i could complete my project.

Thank You!

Try this following code :

Private Sub Text1_Change()
    If IsNumeric(Right(Text1, 1)) = True Then
     ' is a number
        Text1 = Left(Text1, Len(Text1) - 1)
        'Text1.Text = ""
    Else
     'anything but a number
 
    End If
End Sub

Or This 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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.