Visual Basic Tutorial - Part 6, Page 4
Back in tutorial three, we took a look at variables and that terrifying thing they call conditional logic (we saw a bit of that on the last page, with question two).
Let's dive straight in and answer your frequently asked questions...
Q1. What's conditional logic then?
Conditional logic is just the posh name for "checking stuff". Let's pretend you're working on an order system. If the customer order is more than #500, you might want to award them with a free rubber chicken. If it's less than #500, you may want to give them a free rubber dummy.
Conditional logic is just the process of deciding which option to choose. It works something like this..
If txtOrderValue.Text > 500 then MyOrder.AddItem "Free Rubber Chicken" Else MyOrder.AddItem "Poisonous Rubber Dummy" End If
Conditional logic is the "If-Then-Else-End If" bit.
Q2. What kinds of information can a variable hold?
I hope you all recall that a variable is just something you hold information in. In the General Declarations section of your form code, you declare the variable with a line of code, like:
Then you can tell that variable to remember some information by setting it's value in code - with something like:
MyVariable = "Hello There!"
Or you can read its value with something like:
You can also declare a variable to hold a specific type of information, such as a date. To do this, declare it like:
Dim MyVariable as Date
Of course, you could replace the Date bit with any other data type. You could use String to hold a string of text or perhaps Integer to hold a number.
Q3. Hiya Karlos! Are you SURE that picture is of you?
Yes, yes, YES!! The picture is mine. All mine. It's mine!! Stop hassling me, woman. Ed, can't you stop this woman sending me e-mail?
Page 4 of 7