Thursday, November 27, 2008

Major Group Assignment!! Oh no!!

Hello faithful readers!

Me and Jacob are working together on a huge group assignment, worth a huge percentage of our mark. Our objective or purpose for this assignment is to output student report cards on the printer, with a specific format.

The information we're asked to output is as follows:

The person's name, student number, address, grade, city, mark in english, science, math, and computers, with their overall average and status (whether they failed, passed, or got in honours).

We're also required to do calculations, as we're supposed to find the average for each class. This is going to sum up a lot of the stuff we've learned in prior classes, and stuff that we still haven't learned (to the future we gooo!).

For the assignment we're asked to use application paths, in order to get the information much quicker, and so that the person who wants to edit the outputted information doesn't have to fiddle around with the code, rather, they can much easily fiddle around with notepad.

I personally think we have one of the harder questions, since we have stuff that we haven't gotten in-depth with yet, and there's a huge focus around making a much shorter code. However, Jacob and I have the highest marks in the class, so here's hoping and wishful thinking that we do good on this assignment. It's pretty complex, and I don't think we've been able to absorb a lot of the newer concepts these past few days.

Posted by Chris Kaminski at 7:43 PM

Monday, November 24, 2008

The Five Steps in Creating Programs

Welcome back!

Today we discussed the steps in making a program. No, we're not going backwards in the unit, but we're now thoroughly explaining how to make the program, with baby-steps and easy explanations on how we went through the process. Here, let me explain them to you.

First Step: Defining the Problem

This is a detailed description of what you are trying to accomplish, helping you understand the problem much better. Indicating what information will need to be entered, and what information will be outputted is also very important. These descriptions can range from a few short sentences, to hundreds of words.

Second Step: Designing a Solution

Here you show how you will solve the problem. For this, you will be using~

a) User Interface Designs- Rough sketches of how the form(s) will look, with what data you will need as input, and what controls will be required.

b) Form Settings- This is where you describe every object on the form (their properties, new settings, type of object, and purpose).

c) Flow Charts- Charts that use different shapes with different meaning, showing how the program is made.

Third Step: Code the Solution

Here, just as the title of the step outlines, you code the solution.

Fourth Step: Testing and Debugging the Program

After finishing the program, you must then test it, making sure it works, and is also foolproof. The two part you must go through in this step are:

a) Error Handling- Types of errors (syntax/run-time/logic)

b) Debugging Tools- Setting breakpoints, stepping, debug window, and using the watch.

Fifth Step: Document the Program

This is where you finish the program, and put in final touches. The parts in this step include~

a) General Specifications for the Project- Application name, the date it was created, the programmer(s); List of Filenames- Storage location (directory), project file (MAK), global file (GLOBAL.BAS), the many forms (FRM1, 2, etc).

b) Variable Dictionry- Local/module/global variables.

c) Program Comments- Explaining each line of code in the program.

As you can see, we've learned a lot of new info, and here's hoping I can take it all in!

Posted by Chris Kaminski at 4:25 PM

Thursday, November 20, 2008

Test, test, test... again! + Summary

Well, tomorrow's a test! Yay? Boo...

Chiarelli has been telling us that this test would be open-book for the last couple of days. As you could probably understand, I was very happy about that. However, because of a few unnamed students, that privilege, that right, has unfortunately been... :'(... terminated. This really sucks because not only do I have to study much more today, but I also had to finish up a coat of arms for careers, taking up my whole day, and not allowing me to study for the test until now. This sucks, because that means I'll have about 1 hour to study for the test (without visual basic to foolproof the code), and there will be no free time for me to have fun.

Anyways, our review deals with the same stuff we've been doing for the last few days. The homework we've been having after lessons is essentially the exact same program for the 6 different questions on the review~

The first one is based off the do loop until command, requiring the user to enter the radius of a sphere, with the program automatically finding the volume of it.

The second one uses do loop until, and is the exact same problem as the homework question-- converting gallons to litres from 20 to 60 gallons.

The third question is based off finding the sum off numbers with the for next statement. We are asked to find the sum of the following numerical sequence: -22, -17, -12... 473, 478

The fourth question finds all the possible volumes of solids for heights of 4 and 6, lengths of 2, 4, 6, 8, and 10, and widths of 1,2,3 to 14. This program uses the for next concept as well.

The fifth one requires us to use a chart, and allow the user to input numbers which represent the amount of weight gained in kg, outputting the value of the fine (you sign a contract to not gain weight in a year, and have to pay up according to how much weight you have gained).

The sixth one is based off the the assignment me and my partner have been doing for the past few days. The question requires you to input the ages and weights of teenage males, with an average computed of all the inputted numbers, being displayed on a separate form.

As you can see, I need to start studying. So, anyways, see-ya later!

Posted by Chris Kaminski at 9:18 PM

Wednesday, November 19, 2008

Combo Boxes

A combo box is very similar to the option frames we learned about earlier in the unit. They allow you to pick different options by simply clicking your choice. However, unlike the option commands, they do not take a large space, and are all jam-packed in a small scrollable tool (similar to a drop-down menu).

Since there is very little to talk about, I guess I can explain and display the few different types of code that pertain to combo boxes (at least the ones we learned about).

Cboinserthere.additem "whatever"
This code inserts a different option inside of the combo box.

Cboinserthere.listindex = #

This is the original option that the code is on top of when you start the program.

Ugh, as you can see, very little stuff was taught today. The concept is pretty simple, and it will be extremely efficient in future projects, but there just isn't much to talk about it, and that's a bummer (I don't want my blog to be short).

Anyways, until next time!

Posted by Chris Kaminski at 4:39 PM

Thursday, November 13, 2008

For/Next Loops

For/Next Loops are like steps, or stairs, in loops. They allow things to be done much, much quicker, with a lot less lines of code than if you wrote the whole program without loops. How are they stairs, however? Well, these loops move from one loop to another, before redoing the original loop. Confusing? Well, let's get into some more detail!

In these type of loops, you do not use the words "do" or "loop". Instead, you use "for" and "next"

An example of a program using this code is as followed, with me explaining the code~

For insertvariable1= # to # Step #

This line uses a variable, and it allows you to change the number automatically in the loop, with whatever number you want. Essentially, it goes through all these numbers, with a common stepping stone (2, 4, 6... etc).

for insertvariable2= # to # Step #
This line is just like the above, except it's inside the loop. So, when you do the original loop for variable1, you go through this loop as well. Trust me, you'll understand what I'm talking about later.

inservariable2=insertvariable1*insertvariable2
This code will multiple whatever number the first loop is at, with all the different numbers the second loop contains. Essentially, the first number that you are asking to original loop to use will multiply all the numbers that you are 'stepping' through in the second loop.

next insertvariable2
This tells you to redo the loop you are currently in, with the next number in the step.

next insertvariable1
This redoes the whole original loop, doing everything it contains all over again, but with the next number.

*NOTE* This code does not display the information in the form. Common etc.print codes can do the trick, and will be put into each specific loop in order to write the code for that loop, redoing everything.

As you can see, it's some pretty advanced stuff, but I'm sure I'll learn it all later on, and become much more acquainted with it.

Posted by Chris Kaminski at 6:42 PM

Wednesday, November 12, 2008

Do... Loops

Another few days, another few lessons, another few concepts. Do loops, which is the basis of all the lessons we've been learning for the past few days, allow you to loop certain codes, so that you don't have to rewrite them over and over again, and at the same time be able to save lots and lots of time.

Do loops require a do statement at the very beginning, and a loop after all the code you wish to, well, loop. There can be no do without a loop, and likewise there can be no loop without a do. They are always needed in order to fulfill the process of looping a code/function, and are very important in the computer programming world. However, a do loop also needs to end, bringing us to another new concept-- counter controlled repetition.

Counter controlled repetitions allow you to repeat a code a certain amount of times, and refrains the program from repeating the same function over and over again. To properly control these counters, we use do loop until, which, essentially, loops a program until (yes, the code speaks literally for itself) a certain extent. It can be used for a wide of variety of uses, including the ones we took example of today-- adding the sums of a long list of numbers.

Posted by Chris Kaminski at 5:38 PM

Thursday, November 6, 2008

More and More Visual Basic

You know how I said I don't understand everything in VB? Well, yeah, now I do. I don't even need my notes or another program for an example to write my own programs. I just completely understand everything, and the assignments I've been receiving for the past 2 days have been completed in like 10 minutes tops. It doesn't even come down to thinking, and it's about how quick I am with a keyboard and mouse.

The last 2 day's assignments we're based on input boxes, message boxes, other pop up boxes, and if statements.

A message box, well, pops up a message for you to read. It's a simple task to do, and gives you a lot of extra options in writing programs, and assignments.

The code for a message box is~
msgbox "blah blah blah"

An input box allows you to input information, and helps you have variety in programs. Instead of using a textbox, for example, you could use an input box to get information/data from the user. It's gonna be really useful in the future.

The code for an input box is~
inputbox "What is your blah blah blah?"

An if statement is code that switches messages and other things, according to what you do. For example, writing a number under 5 in an input box would pop up a message box saying "that's low" or something, but if you write a number over 5, it would say "that's average. An if statement is very useful, and much more advanced computer programming from what we're accustomed to. It must be foolproof to make sure people can't fool the system, so it requires you to use different codes according to the type of program you're working on.

To start an if statement section, you use the code~

if variable >= # then

The "if" starts it, and the variable is what it determines. It doesn't necessarily need to be a variable, but that's the one we've been using for the past few days. The ">=" means greater than and equals, which is similar to math. You can also use <, which is less than. The "then" refers to what happens once the variable or whatever is before, after, or equaling the statement. A common example, which we used in our prior questions, is using a message box.

Other codes, that deal with if statements include~

elseif, else, and endif
"Elseif" works just like if, but it adds onto what you've said in the beginning of the "if" code; "Else" is whatever else you haven't specified; and endif ends the if statement.

That's what we've been learning for the past few days in TIK201. I'm so glad that I get everything I'm doing, and I'm having lots of fun too!

Posted by Chris Kaminski at 2:06 PM

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 Identification

Dim 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 Values

Private 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 Button

Private 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 Button

Private 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 Button

Private 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 Button

Private Sub CmdExit_Click()
End
This ends the program.
End Sub

Options

Private 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