' Method 1
Function RightLen(sText As String) As Integer
If Len(sText) = 6 Then
RightLen = Left(sText, 4)
Else
RightLen = sText
End If
End Function
' Method 2
Function ValidNum(sText As String) As Integer
If IsNumeric(sText) Then
ValidNum = sText
Else
ValidNum = Left(sText, 4)
End If
End Function
In either instance just use the function to get the actual value and then test against it
Sub CheckValue()
If RightLen(TextBox.Value) > 1000 Then
' Do Something....
End If
End Sub
|