Can someone give me examples of If Then statements!!!
Printable View
Can someone give me examples of If Then statements!!!
VB Code:
Dim HereIsYourExample As Boolean Private Sub Command2_Click() If HereIsYourExample Then HereIsYourExample = Not HereIsYourExample MsgBox "That was your example going by" Else HereIsYourExample = Not HereIsYourExample MsgBox "Here is your example" End If End Sub
I though this thread was a joke at first.
Here are some more complex ones
VB Code:
'Coordinates If x < y then x=x+1 Else x=x-1 End if 'String Length If len(string) = 0 then Msgbox "Your string must be at least 1 character long!" Else Msgbox "Good" End If 'String Comparison If lcase(string) = "this is stupid" and NewbThread = True then Call LOL Else Call PostIf-ThenStatements End If
:)Quote:
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!
Quote:
Originally posted by Illiad
I though this thread was a joke at first
VB Code:
If ThatIsTrue Then YouAndIThinkAlike If ThisQuestionWasAskedByAStudent Then ItMakesABitMoreSense = True Else SomeBodyHasALotOfVB2Learn = True End
VB Code:
If ThisPostHasALotOfIfThenJokes = True Then PerhapsWeShouldStopAllOfTheIfThenJokes = True Else WhateverDoWhateverYouWantToDoLikePostingIfThenJokesBecauseWeAreAllBoredAndWeHaveNothingBetterToDoThanToTypeSentencesWithoutPeriodsOrSpacesOrPunctuation = True End IF
:rolleyes:
this is one way of doing it too:
you can add as many elseif's as u want
VB Code:
' really basic method of using ' IF THEN ==== ELSEIF THEN ==== ELSE ==== END IF If Text1.Text = "Hello" Then MsgBox "Hello!" ElseIf Text1.Text = "Goodbye" Then MsgBox "See ya later pal!" Else MsgBox "Look dood, i dont have the foggiest idea what you just said to me!" End If ' however, if its only the value of text1.text you want to ' check, use the following: Select Case Text1.Text Case "Hello": MsgBox "Hello!" Case "Goodbye": MsgBox "See ya later pal!" Case Else: MsgBox "Look dood, i dont have the foggiest idea what you just said to me!" End Select
hi,
if u want to check maximum number then try this
if a>b then
max=a
else
max=b
end if
VB Code:
If me.threadlength >= 2pages and me.threadlength <= 4 then Call ModeratorsClearThread Else Call PostFunnyVBcode End if