K
kartune85
I've used the following code to try and restrict certain characters to a
textbox:
Private Sub TextBox2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case Asc(".")
If InStr(1, Me.TextBox1.Text, ".") > 0 Then
KeyAscii = 0
End If
End Select
End Sub
The period is not the only character I'm trying to restrict but it is
one of them. Whenever I've tried to use 'Select Case', the code never
seems to do anything... at all. The Textbox2 is used as the savename so
I can't allow any weird characters to get typed in.
Can anyone help me out regarding this?
Thanks,
Kartune85
textbox:
Private Sub TextBox2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case Asc(".")
If InStr(1, Me.TextBox1.Text, ".") > 0 Then
KeyAscii = 0
End If
End Select
End Sub
The period is not the only character I'm trying to restrict but it is
one of them. Whenever I've tried to use 'Select Case', the code never
seems to do anything... at all. The Textbox2 is used as the savename so
I can't allow any weird characters to get typed in.
Can anyone help me out regarding this?
Thanks,
Kartune85