Wednesday, 9 February 2011

The IF, ELSEIF, ELSE statements

The If statement is a way of saying If this is activated, then do this, and if it isn't like that then do this so like this.

If randomnumber = 2 then
   MsgBox("The random number = 2")
ElseIf randomnumber = 3 then
  MsgBox("The Random number = 3")
Else
  MsgBox("the randomnumber is neither 2 or 3")
End If

So basicly what i made the program do is tell me if the random number is 2, 3 or none of them.

Very simple, but they can get very complicated, you can also call other subs or functions from the If statements

exampel:

 If textbox1.text = "Hello World" then
  HelloWorld()
Elseif
  textbox1.text = "Goodbye World" then
  GoodbyeWorld()
End If
  So yea with If statements, there are a lot possibilities!

-Rasmus Iversen

No comments:

Post a Comment