Results 1 to 6 of 6

Thread: or statement

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    MN
    Posts
    362

    or statement

    How can I use an OR staement in an If/else block? see examle:
    If text1.text = "jan" or "cindy" or "lisa" Then
    end If
    That would be what I need to do, but that doesnt work.
    Any ideas?

  2. #2
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    Try using a Select...Case statement instead:

    VB Code:
    1. Select Case Text1.Text
    2.    Case "Marcia", "Jan", "Cindy"
    3.        'Do Stuff
    4.  
    5.    Case Else
    6.       'Do other stuff
    7.  
    8. End Select

    This would be more appropriate to your solution, I would sauy, but if you must use an if-block, you need to do it like so:

    VB Code:
    1. If ((text1.text = "jan") or (text1.text = "cindy") or (text1.text = "lisa")) Then
    2. end If
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  3. #3
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    VB Code:
    1. If Text1.Text = "jan" Or Text1.Text = "cindy" Or Text1.Text = "lisa" Then

    a better way is to use Select Case

    VB Code:
    1. Select Case UCase(Text1.Text)
    2.         Case "JAN"
    3.             'do stuff
    4.         Case "CINDY"
    5.             'do Cindy stuff
    6.         Case "LISA"
    7.             'do it to lisa
    8.         Case Else
    9.             'if none of the above
    10.     End Select
    -= a peet post =-

  4. #4
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    Too slow, Norweigian.
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  5. #5
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    ok... this is a bit scary
    -= a peet post =-

  6. #6
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    It's like Anti-Trust.... now where'd you hide the camera you sneak?!?
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

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