Tuesday, August 3, 2010

Tuesday, August 3rd

Using the tutorial written by Jesse Liberty, I have had some trouble getting the Search Criteria Builder to work.

I am going to take a break from the Jesse Liberty tutorial and focus on one written by Anne Boehm. This tutorial deals with coding control structures, and I am quite happy to see that we will be learning how to write nested If statements. The example Anne Boehm gives (which is used in an expanded form in the tutorial) is:


If customerType = "R" Then
If subtotal >= 100 Then
discountPercent = .2D
Else
discountPercent = .1D
End If
Else
discountPercent = .4D
End If


I can use nested If statements to develop a personal project of mine - one that would figure exactly how much take home pay you were bringing home after federal and state taxes, and what percentage of your pay would be spent on a purchase item (including telling you what the total purchase cost of the item will be with your local sales tax). There would be three input fields - two blank text boxes for entering your yearly salary and cost of the item you wish to purchase and one combo box using a scroll down list of states.

For the tutorial we have a variable defined as discountPercent, which is defined using an If statement with two nested If statements within it, each of these nested If statements defines the discount according to the amount purchased and the customer type, if the customer type is "R" or "C" then there is a special discount amount depending on how much is purchased. All other customers get a flat rate.

Next, I took a look at For loops with a syntax of:


For counter [As datatype] = start To end [Step step]
statements
Next [counter]


Using i as the counter name is common coding practice, since counters can also be referred to as indexes

No comments: