on text1.text, I have 5 characters, how can I check to make sure that none of them are the same
like:
how do I get it work?Code:if text1.text include 2 same characters then
bla bla bla
else:
bla bla bla
Printable View
on text1.text, I have 5 characters, how can I check to make sure that none of them are the same
like:
how do I get it work?Code:if text1.text include 2 same characters then
bla bla bla
else:
bla bla bla
You may try:
For c = 1 to Len(Text1.Text) - 1
If Instr(Mid$(Text1.Text, c+1), Mid$(Text1.Text, c, 1)) <> 0 Then
' Found 2 or more
Else
' Not Found
End If
Next
Hope this is what you want
thanks
That is significantly slow method, you could use Like operator:
Code:'In declarations
Option Compare Text
'In code
For X=65 to 90
IF Text1.Text Like "*" & chr(x) & "*" & chr(x) & "*" Then
Msgbox "Contains 2 same characaters"
Exit For
End if
Next X
kedaman's solution is perfect, as long as there is only alpha data in the textbox...doesn't work with numbers as their dec value is not included.
well accutually I have numbers and letters
You can change For X=whatever to whatever, you can even exclude some characters if you make an array of x values
Code:'In declarations
Option Compare Text
'In code
For X=48 to 90
IF Text1.Text Like "*" & chr(x) & "*" & chr(x) & "*" Then
Msgbox "Contains 2 same characaters"
Exit For
End if
Next X
thanks, but all ready made everything using the other medthods, but thanks anyway