Hello and thank you for any attention this post may receive.
So I have a userform (frmInput) which has 25 texboxes (TextBox1 to TextBox25) and all of which have the 'MaxLength' set to 8, and restricted to numbers only. However this still allows me to input any length of characters from 1 to 8. I would like all 25 textboxes to only accept blank or 8char. Not sure how to do this. I have looked online but can only really find a character limit which is not exactly what I am after.
Any thoughts would be greatly appreciated.
This is the code (I found on www) to limit textbox input to numbers only.
Cheers and have a great day!
So I have a userform (frmInput) which has 25 texboxes (TextBox1 to TextBox25) and all of which have the 'MaxLength' set to 8, and restricted to numbers only. However this still allows me to input any length of characters from 1 to 8. I would like all 25 textboxes to only accept blank or 8char. Not sure how to do this. I have looked online but can only really find a character limit which is not exactly what I am after.
Any thoughts would be greatly appreciated.
This is the code (I found on www) to limit textbox input to numbers only.
Code:
Private Sub InputTextBox_keypress _
(ByVal KeyAscii As msforms.ReturnInteger)
'Allows only numbers.
'Dim sText
Select Case KeyAscii
Case 47 To 57
Case Else
KeyAscii = 0
End Select
'Save the text in a variable
sText = InputTextBox.Text
End Sub
Cheers and have a great day!
Last edited: