I want my text box to allow a minimum of 8 digits and I have been using the following code but it does not work.
Private Sub StudentID_Change()
If StudentID.TextLength = 1 Then
MsgBox "Please enter a 8 digits"
StudentID.SetFocus
ElseIf StudentID.TextLength = 2 Then
MsgBox "Please enter a 8 digits"
StudentID.SetFocus
ElseIf StudentID.TextLength = 3 Then
MsgBox "Please enter a 8 digits"
StudentID.SetFocus
ElseIf StudentID.TextLength = 4 Then
MsgBox "Please enter a 8 digits"
StudentID.SetFocus
ElseIf StudentID.TextLength = 5 Then
MsgBox "Please enter a 8 digits"
StudentID.SetFocus
ElseIf StudentID.TextLength = 6 Then
MsgBox "Please enter a 8 digits"
StudentID.SetFocus
ElseIf StudentID.TextLength = 7 Then
MsgBox "Please enter a 8 digits"
StudentID.SetFocus
End If
End Sub

However, every time that I run this code and try to enter one digit in the text box, it comes up with the pop up saying "Please enter a 8 digits" and the same again when i enter the second digit.

Any help?