Results 1 to 8 of 8

Thread: no 2 same characters

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    on text1.text, I have 5 characters, how can I check to make sure that none of them are the same


    like:

    Code:
    if text1.text include 2 same characters then
    bla bla bla
    else:
    bla bla bla
    how do I get it work?
    NXSupport - Your one-stop source for computer help

  2. #2
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Taipei
    Posts
    318

    Cool

    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

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    thanks
    NXSupport - Your one-stop source for computer help

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    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.
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    well accutually I have numbers and letters
    NXSupport - Your one-stop source for computer help

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    thanks, but all ready made everything using the other medthods, but thanks anyway
    NXSupport - Your one-stop source for computer help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width