validation rule, input mask?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
how can I make sure input in a text box would be like following:
xxxx/nn where xxxx is a number and its number of digits (one digit or more)
may vary and the nn is two digit string (number that may start with zero)
thanx
alek_mil
 
Private Sub MyTextBox_BeforeUpdate(Cancel As Integer)

Dim intLength As Integer

If IsNull(Me.MyTextBox) Then
Cancel = True
Else
intLength = Len(Me.MyTextBox)
If intLength < 4 Then
Cancel = True
Else
Cancel = (Mid$(Me.MyTextBox, intLength - 2, 1) <> "/") _
Or Not IsNumeric(right$(Me.MyTextBox, 2))
End If
End If

If Cancel = True Then
MsgBox "Input is invalid"
End If

End Sub
 
Back
Top