Results 1 to 11 of 11

Thread: If Then Statements?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Location
    Atlanta Ga.
    Posts
    177

    If Then Statements?

    can someone give me examples of If Then statements..

  2. #2
    Lively Member
    Join Date
    Jul 2002
    Location
    California
    Posts
    77

    Question

    You are a lively member. Not that this really means anything, but If Then Statements are basic to programming from the beginning.

    Is there something specific you are looking for?

  3. #3
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    I agree, you should have learned If...Then...Else statements within the first 2 weeks of any programming class.

    VB Code:
    1. Dim a As Integer
    2.  
    3. a = 10
    4.  
    5. If(a = 10) then
    6.    'process some code here
    7. Else
    8.    'process some code here
    9. End If

    Oh, and please don't double post...You have 8 replies in your other post asking the same question.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  4. #4
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,969
    I'm new at all this so I don't mind helping with IF/Then/Else 101:

    Here are some basics:

    If A = B then
    do something
    end if

    If A = B then
    do something
    elseif A = C then
    do something else
    end if

    If A = B then
    If A = C then
    do something
    end if
    else

    end if

    It helps alot if you use proper indentation.

  5. #5
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,969
    I'm new at all this so I don't mind helping with IF/Then/Else 101:

    Here are some basics:

    If A = B then
    do something
    end if

    If A = B then
    do something
    elseif A = C then
    do something else
    end if

    If A = B then
    If A = C then
    do something
    end if
    else
    do something else
    end if

    It helps alot if you use proper indentation.

  6. #6
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629
    The way I use it.

    If your testing one condition expression against several possible values then use Select Case instead of If...ElseIf...End If

    VB Code:
    1. Select Case A
    2. Case B
    3.    'Statements
    4. Case C
    5.    'Statements
    6. Case Else  'A <> B, A <> C
    7.    'Statements
    8. End Select

    If your testing several condition expressions then use If...ElseIf...End If.
    VB Code:
    1. If A = B Then
    2.    'Statements
    3. ElseIf A + C = B Then
    4.    'Statements
    5. Else
    6.    'Statements
    7. End If

    I hardly use If...ElseIf...End If. Add an About Form to see a sample of If...ElseIf...End If.

  7. #7
    Lively Member
    Join Date
    Jul 2002
    Location
    California
    Posts
    77
    I don't think any of us mind helping. In fact, Memnoch1207 even gave an example. I just wanted to know more specifics to give a better answer.

    Now I understand. Personally, I love the SELECT statement. I prefer that over ELSEIF. That just looks to confusing. The SELECT statement I think is much cleaner.

    Just my humble (only a 'member') opinion.

    How does one use proper indention on this website anyway?

  8. #8
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    And there's this :

    VB Code:
    1. Iff(a=1,b=1,b=2)
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  9. #9
    Fanatic Member demotivater's Avatar
    Join Date
    Jun 2002
    Location
    is everything
    Posts
    627
    Originally posted by Virgil J. Schmidt
    How does one use proper indention on this website anyway? [/B]
    Enclose "vbcode" in brackets to start the code sample, then enclose "/vbcode" in brackets to end the sample. (Without the quotes)

  10. #10
    Lively Member
    Join Date
    Jul 2002
    Location
    California
    Posts
    77
    True, True

    I thougth of that, but I usually use that to complete an equation.

    X = iff(a=y, b,c)

    So I didn't consider it was the same in this case.
    Last edited by Virgil J. Schmidt; May 13th, 2003 at 03:44 PM.

  11. #11
    Lively Member
    Join Date
    Jul 2002
    Location
    California
    Posts
    77
    Originally posted by demotivater
    Enclose "vbcode" in brackets to start the code sample, then enclose "/vbcode" in brackets to end the sample. (Without the quotes)
    Thank you.

    So

    VB Code:
    1. X = iff(a=y, b,c)

    Hey, it works...Sorry for the thread interuption.

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