Results 1 to 4 of 4

Thread: The IF statement

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 1999
    Location
    Selma, NC, USA
    Posts
    25

    Post

    I will probably get laughed out of this forum but I need to know how to check for more than on thing in an IF statement.

    Ex. if richtextbox1.text = ^6,^7,^8,^9 then
    whatever...

    I don't want to have to nest if statements if at all possible. Please help.

    GiD

  2. #2
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523

    Post

    You could use OR Operator.
    Code:
        With Text1
        If .Text = "^6" Or .Text = "^7" Then
            'Do whatever you want
        End If
        End With
        'you don't have to use With statement
        'it just makes code look less
        'complicated to me (and shorter too)
    Hope this will help


    ------------------
    Visual Basic Programmer
    -----------------
    PolComSoft
    You will hear a lot about it.



    [This message has been edited by QWERTY (edited 11-04-1999).]

  3. #3
    Junior Member
    Join Date
    Oct 1999
    Posts
    31

    Post

    Use OR keyword.

    If something = "BLAH" or something = "MORE BLAH" Then
    do something.
    End if

    If you can multiple different cases you want to check you can also user Select Case.

    SELECT CASE richtextbox1.txt

    CASE 1
    do something
    CASE 2
    do something
    CASE 6,7,8,9
    do something
    END SELECT


  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jul 1999
    Location
    Selma, NC, USA
    Posts
    25

    Post

    Thanks a lot guys. I had a brain fart there!

    GiD

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