Results 1 to 8 of 8

Thread: = this or that question (string)

  1. #1

    Thread Starter
    Addicted Member killer_cobra's Avatar
    Join Date
    Jun 2001
    Location
    Lost in space
    Posts
    131

    = this or that question (string)

    Hi,
    I have a have several strings that are only unique by the last 3 characters and I need to put in an if statement.

    However I am having trouble with it:

    If not Right (listbox1, 3) = "123" OR "234" or "345" then
    DoWhatever
    End if

    You should notice that the above code doesn't work. (As I just found out). I need it to be able to do what the above code says in plain english (not vb terms). So basically if it doesn't match any of those then it goes to DoWhatever. I could do this with multiple If-Else-End if statements, but I'm wondering if there is a way to do this similar to the provided code? Am I missing some keyword? (tried a lot of them too).

    Thanx in advance,

    Scott
    Error... What Error?!?! I've only typed a single character!
    ______________________________
    VB 6.0 EE, Win 2k Pro on AMD Duron 1Ghz/ 384 MB SDRAM

  2. #2
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    maybe commas instead of OR im probly wrong tho i havent learned about the OR staement yet

  3. #3
    Addicted Member eanilarora's Avatar
    Join Date
    Aug 2000
    Location
    Malaysia
    Posts
    179
    VB Code:
    1. If Not (Right(myStr, 3) = "123" Or Right(myStr, 3) = "234" Or "345") Then
    2.     'Do Whatever
    3. End If

    The Left side of the operator = has to be given everytime
    Love, Live, Laugh

  4. #4
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    aaaaaw...

  5. #5
    Fanatic Member rudvs2's Avatar
    Join Date
    Mar 2001
    Location
    NZ
    Posts
    935
    okay try doing this

    VB Code:
    1. Dim strData As String
    2.  
    3. strData = Right(list1.List(1),3)  
    4. 'In your code you did not specify the listbox list index that you
    5. 'wanted to use you will probably need to place some code a for
    6. 'next statement to encapsualte this code and step through your
    7. 'list or something depending what you want to do
    8.  
    9. Select Case StrData
    10.  
    11.      Case Is = "123", "234", 345"
    12.           'your stuff here
    13.  
    14.      Case Else
    15.           'If no match here
    16.  
    17. End Select

  6. #6
    Addicted Member eanilarora's Avatar
    Join Date
    Aug 2000
    Location
    Malaysia
    Posts
    179
    Originally posted by Motoxpro
    aaaaaw...
    Did my reply pinch u or what
    Love, Live, Laugh

  7. #7
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    no like aaa ok hehe

  8. #8
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    VB Code:
    1. StrData = Right(myStr, 3)
    2. If Not StrData = "123" Or Not StrData = "234" Or Not StrData =  "345" Then
    3.     'Do Whatever
    4. End If

    I think that should also work

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