Results 1 to 9 of 9

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
    Fanatic Member Armbruster's Avatar
    Join Date
    Sep 2002
    Location
    Maryland Heights, MO
    Posts
    857
    VB Code:
    1. Dim HereIsYourExample As Boolean
    2. Private Sub Command2_Click()
    3.    
    4.     If HereIsYourExample Then
    5.         HereIsYourExample = Not HereIsYourExample
    6.         MsgBox "That was your example going by"
    7.     Else
    8.         HereIsYourExample = Not HereIsYourExample
    9.         MsgBox "Here is your example"
    10.     End If
    11. End Sub
    "Look! Up in the sky! It's a bird! It's a plane! It's Diaper-Head Boy! (there by my name!) Yes, Diaper-Head Boy, who disguised as my son, Seth, fights a never-ending battle for truth, justice and terrorizing my house!

    Resistance is futile, you will be compiled . . . Please!

  3. #3
    Addicted Member Illiad's Avatar
    Join Date
    Mar 2003
    Location
    Chicago
    Posts
    196
    I though this thread was a joke at first.
    Here are some more complex ones

    VB Code:
    1. 'Coordinates
    2. If x < y then
    3.    x=x+1
    4. Else
    5.    x=x-1
    6. End if
    7. 'String Length
    8. If len(string) = 0 then
    9.    Msgbox "Your string must be at least 1 character long!"
    10. Else
    11.    Msgbox "Good"
    12. End If
    13. 'String Comparison
    14. If lcase(string) = "this is stupid" and NewbThread = True then
    15.    Call LOL
    16. Else
    17.    Call PostIf-ThenStatements
    18. End If
    Quis Custodiet Ipsos Custodes?

    You don't have to be faster than the bear, you just have to be faster than the slowest person running from the bear.

  4. #4
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849

    IF

    If you can keep your head when all about you
    Are losing theirs and blaming it on you,
    If you can trust yourself when all men doubt you
    But make allowance for their doubting too,
    If you can wait and not be tired by waiting,
    Or being lied about, don't deal in lies,
    Or being hated, don't give way to hating,
    And yet don't look too good, nor talk too wise:
    If you can dream--and not make dreams your master,
    If you can think--and not make thoughts your aim;
    If you can meet with Triumph and Disaster
    And treat those two impostors just the same;
    If you can bear to hear the truth you've spoken
    Twisted by knaves to make a trap for fools,
    Or watch the things you gave your life to, broken,
    And stoop and build 'em up with worn-out tools:

    If you can make one heap of all your winnings
    And risk it all on one turn of pitch-and-toss,
    And lose, and start again at your beginnings
    And never breath a word about your loss;
    If you can force your heart and nerve and sinew
    To serve your turn long after they are gone,
    And so hold on when there is nothing in you
    Except the Will which says to them: "Hold on!"

    If you can talk with crowds and keep your virtue,
    Or walk with kings--nor lose the common touch,
    Ifneither foes nor loving friends can hurt you;
    If all men count with you, but none too much,
    If you can fill the unforgiving minute
    With sixty seconds' worth of distance run,
    Yours is the Earth and everything that's in it,
    And--which is more--you'll be Man, my son!

    "Brothers, you asked for it."
    ...Francisco Domingo Carlos Andres Sebastian D'Anconia

  5. #5
    Fanatic Member Armbruster's Avatar
    Join Date
    Sep 2002
    Location
    Maryland Heights, MO
    Posts
    857
    Originally posted by Illiad
    I though this thread was a joke at first
    VB Code:
    1. If ThatIsTrue Then YouAndIThinkAlike
    2.    
    3.     If ThisQuestionWasAskedByAStudent Then
    4.         ItMakesABitMoreSense = True
    5.     Else
    6.         SomeBodyHasALotOfVB2Learn = True
    7.     End
    "Look! Up in the sky! It's a bird! It's a plane! It's Diaper-Head Boy! (there by my name!) Yes, Diaper-Head Boy, who disguised as my son, Seth, fights a never-ending battle for truth, justice and terrorizing my house!

    Resistance is futile, you will be compiled . . . Please!

  6. #6
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    VB Code:
    1. If ThisPostHasALotOfIfThenJokes = True Then
    2. PerhapsWeShouldStopAllOfTheIfThenJokes = True
    3. Else
    4. WhateverDoWhateverYouWantToDoLikePostingIfThenJokesBecauseWeAreAllBoredAndWeHaveNothingBetterToDoThanToTypeSentencesWithoutPeriodsOrSpacesOrPunctuation = True
    5.  
    6. End IF

    Remember, if someone's post was not helpful, you can always rate their post negatively .

  7. #7
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065
    this is one way of doing it too:

    you can add as many elseif's as u want
    VB Code:
    1. ' really basic method of using
    2.     ' IF THEN ==== ELSEIF THEN ==== ELSE ==== END IF
    3.     If Text1.Text = "Hello" Then
    4.         MsgBox "Hello!"
    5.        
    6.     ElseIf Text1.Text = "Goodbye" Then
    7.         MsgBox "See ya later pal!"
    8.        
    9.     Else
    10.         MsgBox "Look dood, i dont have the foggiest idea what you just said to me!"
    11.    
    12.     End If
    13.    
    14.     ' however, if its only the value of text1.text you want to
    15.     ' check, use the following:
    16.    
    17.     Select Case Text1.Text
    18.         Case "Hello":
    19.             MsgBox "Hello!"
    20.        
    21.         Case "Goodbye":
    22.             MsgBox "See ya later pal!"
    23.        
    24.         Case Else:
    25.             MsgBox "Look dood, i dont have the foggiest idea what you just said to me!"
    26.        
    27.     End Select
    Wayne

  8. #8
    Hyperactive Member
    Join Date
    Nov 2002
    Location
    india
    Posts
    418
    hi,

    if u want to check maximum number then try this

    if a>b then
    max=a
    else
    max=b
    end if

  9. #9
    Addicted Member Illiad's Avatar
    Join Date
    Mar 2003
    Location
    Chicago
    Posts
    196
    VB Code:
    1. If me.threadlength >= 2pages and me.threadlength <= 4 then
    2.    Call ModeratorsClearThread
    3. Else
    4.    Call PostFunnyVBcode
    5. End if
    Quis Custodiet Ipsos Custodes?

    You don't have to be faster than the bear, you just have to be faster than the slowest person running from the bear.

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