Monday, November 3, 2008
Test + Family Project Mark= Awesome
So today we had our test in TIK 201, and I did really, really good. I was probably done about 10 minutes before everyone else, incorporating everything that was needed into the program, with so much time to spare! Since I have nothing better to do, I'll explain the coding in my program.
First off, I used different objects from the toolbox, in order to make it exactly like the test example.

As you can see, I used different objects for different uses. Labels we're used for anything that only outputted information, and did not require any input. Textboxes we're needed for the input, so that you can write the information you want. Commands we're used, and images made like commands, so that when you press them, certain operations occur.
Here's the coding part, with each line being explained. For the sake of time, I won't repeat the explanation for every line, but say them once, and when that code reappears, I'll let it go.
General IdentificationDim SmallSize, MediumSize, LargeSize, XLSize, BasicPizza, VeggiePizza, MeatPizza, StuffedPizza, DeluxePizza As Double
This allows you to refer to different values, as their names given here. They help you throughout the program, as they given a common identfier of each value.General Identifier ValuesPrivate Sub Form_Load()
This is what happens when you first load up the program.SmallSize = 4.99
These are the values given to each identifier.MediumSize = 5.99
LargeSize = 7.99
XLSize = 9.99
BasicPizza = 0.89
VeggiePizza = 1.49
MeatPizza = 2.07
StuffedPizza = 3.45
DeluxePizza = 4.75
End Sub
Print ButtonPrivate Sub imgprint_Click()
This initiates the code- clicking.frmshop.PrintForm
This prints the form, and all the information/data that was given/received.End Sub
This ends the code.Compute ButtonPrivate Sub imgcompute_Click()
lblsub.Caption = Val(lblprice.Caption) * Val(txtquantity.Text)
This multiplies the quantity (or number) of what you're buying (which in this case is pizza), by the price.lbltax.Caption = Val(lblsub.Caption) * 0.15
This multiplies the sub total by 0.15, which gives you the taxes for the order.lbltotal.Caption = Val(lblsub.Caption) + Val(lbltax.Caption)
This adds the sub total with the taxes, giving you the total price for the order.lblbase.Caption = Format$(lblbase.Caption, "currency")
This, just like all the lines following, switches all the numbers that deal with money, as currency, giving you the money sign, rounding the numbers, etc.lblsurcharge.Caption = Format$(lblsurcharge.Caption, "currency")
lblprice.Caption = Format$(lblprice.Caption, "currency")
lblsub.Caption = Format$(lblsub.Caption, "currency")
lbltax.Caption = Format$(lbltax.Caption, "currency")
lbltotal.Caption = Format$(lbltotal.Caption, "currency")
CmdNew.SetFocus
This sets the focus on the "new button".End Sub
New ButtonPrivate Sub CmdNew_Click()
txtname.Text = ""
This, just like all the lines in this group of codes, erases all the numbers in the form, so that it starts off fresh, allowing you to restart the program.lblbase.Caption = ""
lblsurcharge.Caption = ""
lblprice.Caption = ""
txtquantity.Text = ""
lblsub.Caption = ""
lbltax.Caption = ""
lbltotal.Caption = ""
OptSmall.Value = False
This, just like all the lines in this group of codes, takes off the selection of any options, allowing you to start fresh in the program.OptMedium.Value = False
OptLarge.Value = False
OptXLarge.Value = False
OptBasic.Value = False
OptVeggie.Value = False
OptMeat.Value = False
OptStuffed.Value = False
OptDeluxe.Value = False
End Sub
End ButtonPrivate Sub CmdExit_Click()
End
This ends the program.End Sub
OptionsPrivate Sub OptMedium_Click()
lblbase.Caption = MediumSize
When this is selected, the label called "lblbase" has it's caption, or text, refer to the value of "medium size". For the other options, which I won't repeat for the sake of not having to type the same thing out over and over again, you just switch the identifier, which has its own value.lblprice.Caption = Val(lblsurcharge.Caption) + Val(lblbase.Caption)
This makes it so that the price label changes every time you select an option. It adds the item surcharge with the base price.End Sub
That is pretty much the program summed up. I didn't identify and explain everything, but most of it has been explained.
On another short note, I got my family project mark while doing my exam. A whopping 49/50! Whoo! I'm pretty happy, but I'm also sad for losing my perfect streak, but whatever. One little mistake won't have that much of an impact on my mark.
Posted by Chris Kaminski at 12:50 PM