
Originally Posted by
odamsr
But it could be any numbers from 0-9. Would you have to create a function for each? I thought about testing positions 1 & 2 to see if they are the same and if they aren't exit the function and if they are test position 2 & 3 and then repeat the process. Would that work?
Thanks
Shannon
I just took what Martin posted, and put it into a Function. Just enter the number string you wish to test in text1.text
VB Code:
Option Explicit
Private Function AreNumbersAlike(plngCheckNum As Long) As Boolean
Dim lngIndex As Long
Dim bDifferent As Boolean
For lngIndex = 1 To 9
If Mid$(plngCheckNum, lngIndex, 1) <> Left$(plngCheckNum, 1) Then
bDifferent = True
Exit For
End If
Next
AreNumbersAlike = bDifferent
End Function
Private Sub Command1_Click()
If AreNumbersAlike(Val(Text1.Text)) Then
MsgBox "They are different"
Else
MsgBox "They are all the same"
End If
End Sub
Modify as necessary.