This should work. If you want to put the CheckText in a Module, just change the declaration to public.

Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)

Dim lret As Long

lret = CheckText(KeyAscii)
KeyAscii = lret

End Sub


Private Function CheckText(ByVal KeyAscii As Integer) As Long


Dim strChar As String

' Accept the key if its a "control character" ...
If KeyAscii < 32 Then
CheckText = KeyAscii
Exit Function
End If

strChar = Chr$(KeyAscii)

' Accept the key if it's numeric ...
If strChar >= "0" And strChar <= "9" Then
CheckText = KeyAscii
Exit Function
End If
strChar = UCase$(strChar)

' Accept the key if it's alpha ...

If strChar >= "A" And strChar <= "Z" Then
CheckKey = KeyAscii
Exit Function
End If

' Otherwise, reject the key ...
KeyAscii = 0
CheckText = KeyAscii

End Function
Hope this helps

(VB 6 SP3)