Introduction
(Replace this with: What is the purpose or problem that the program is trying to solve
The purpose of the program Visual Basic is to work with the code I have given and make sure that there are no errors and to warn the user if there are any, if not it should me that the game you have created should work fine due to no errors in typing or statements.
In my case its duty is to see who wins the game I created of noughts and crosses. The game has been made to only for two players. Once the decision on players has been final, the game begins by the "Player Turn" presenting which player will begin whether its "X" or "O".
The game will continue and until the result ends with one player as the winner or a tie.
A small notification will appear finalising the winner of that round. To keep score that winning player will then recieve a tally/ number next to their "X" or "O" to represent that they have one a round and it will continue until the players decide to end the game.
Once the round is over, the player(s) must clickon the restart button for the game to begin again and the "Player Turn" will switch over to the opposite player, so there are equal turns on which player begins the game!
Algorithm Outlining the Program
(Put your flow chart here)
Explanation of Data Types used
(What types are used in the variables in your program and where? Remember the DIM statement)
(not complete!!)
Tuesday, September 21, 2010
Tic Tac Toe Game Done!!!
Last lesson, I completed my term 3 IST assignment which was to create our own game on Visual Basic.
I researched and watched different tutorials to help me understand the process of making the game including the form, the buttons, labels and then the code and making the game work.
Once the actual game was done I decorated it, so that it wouldn't look plain, I added a background of a purple flower and then changed the colour of the fonts, font sizes etc.
All I have to now is upload the game to a document and finish off my theory and then I am done!! =P
I researched and watched different tutorials to help me understand the process of making the game including the form, the buttons, labels and then the code and making the game work.
Once the actual game was done I decorated it, so that it wouldn't look plain, I added a background of a purple flower and then changed the colour of the fonts, font sizes etc.
All I have to now is upload the game to a document and finish off my theory and then I am done!! =P
Wednesday, August 25, 2010
Hi LO Guessing Game
Study the code below;
Public Class Form1
Dim secretnum As Integer = Int (10 * Rnd() ) + 1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text <>Then TextBox2.Text = "higher"
If TextBox1.Text > secretnum Then TextBox2.Text = "lower"
If TextBox1.Text = secretnum Then TextBox2.Text = "correct"
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Randomize ()
Secretnum = Int (10 * Rnd() ) + 1
TextBox1.Text = ""
TextBox2.Text = ""
End Sub
End Class
Answer the following:
1. How many objects are referred to? What are they?
2.What is the name of the variable referred to?
3. What are the three text options that appear in textbox1?
4. What do you think this code does?
5. Build this code into a project and get it to work!!
Public Class Form1
Dim secretnum As Integer = Int (10 * Rnd() ) + 1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text <>Then TextBox2.Text = "higher"
If TextBox1.Text > secretnum Then TextBox2.Text = "lower"
If TextBox1.Text = secretnum Then TextBox2.Text = "correct"
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Randomize ()
Secretnum = Int (10 * Rnd() ) + 1
TextBox1.Text = ""
TextBox2.Text = ""
End Sub
End Class
Answer the following:
1. How many objects are referred to? What are they?
2.What is the name of the variable referred to?
3. What are the three text options that appear in textbox1?
4. What do you think this code does?
5. Build this code into a project and get it to work!!
Simple Timer
Simple Timer
The timer object is quite simple to use. It is an invisible object that runs in the background of a form. The timer has one event, a timer event occurs every time the time interval expires.
For example if you set the timer interal to 1000(1 second), then every second a timer event will occur. You can code what happens when the timer event is triggered, just make sure the timers enabled property is set to true.
For Example:
Define a variable in the form-
Dim clock as integer
Place the following code in the timer event
clock=clock+1
label1.text=clock
You could add two buttons, one to start the timer and one to stop the timer. Starting the timer would involve setting the "clock" variable to 0 and the timer enabled property to true. Stop the timer simply involves setting the timer enabled property to false.
The timer object is quite simple to use. It is an invisible object that runs in the background of a form. The timer has one event, a timer event occurs every time the time interval expires.
For example if you set the timer interal to 1000(1 second), then every second a timer event will occur. You can code what happens when the timer event is triggered, just make sure the timers enabled property is set to true.
For Example:
Define a variable in the form-
Dim clock as integer
Place the following code in the timer event
clock=clock+1
label1.text=clock
You could add two buttons, one to start the timer and one to stop the timer. Starting the timer would involve setting the "clock" variable to 0 and the timer enabled property to true. Stop the timer simply involves setting the timer enabled property to false.
Tuesday, August 17, 2010
Variables
Variables are "containers" for values that can be used by a program. Variables can contain numbers or text. Variables are given names so they can be referred to in the programming code.
Today, I will create three variables, one called "point", one called "number", and one called "name".
Program used: Microsoft Visual Basic
Once I had a new form, I had to add three buttons from the toolbox to the form and change the names from:
* Button1 to Whole Number
* Button2 to Decimal Number
* Button3 to Name
I then added 3 Labels one beside each of the buttons and then a text box below the Name button.
I then changed the codes for the buttons:
Private Sub Button1_Click (ByVal sender As System. Object, ByVal e As System. EventArgs)
Handles Button1.Click
number = Rnd ()
Label1.Text = number
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System. EventArgs)
Handles Button2.Click
point = Rnd ()
Label2.Text = point
End Sub
Private Sub Button3_Click (ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button3.Click
myname = TextBox1.Text
Label3.Text = myname
End Sub
The following are the screenshots of my end result for this class task.
The first screenshot is of the codes which is what makes the program run.
The second screenshot is of the actual program/form that I made.

Today, I will create three variables, one called "point", one called "number", and one called "name".
Program used: Microsoft Visual Basic
Once I had a new form, I had to add three buttons from the toolbox to the form and change the names from:
* Button1 to Whole Number
* Button2 to Decimal Number
* Button3 to Name
I then added 3 Labels one beside each of the buttons and then a text box below the Name button.
I then changed the codes for the buttons:
Private Sub Button1_Click (ByVal sender As System. Object, ByVal e As System. EventArgs)
Handles Button1.Click
number = Rnd ()
Label1.Text = number
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System. EventArgs)
Handles Button2.Click
point = Rnd ()
Label2.Text = point
End Sub
Private Sub Button3_Click (ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button3.Click
myname = TextBox1.Text
Label3.Text = myname
End Sub
The following are the screenshots of my end result for this class task.
The first screenshot is of the codes which is what makes the program run.
The second screenshot is of the actual program/form that I made.


Control Structures-Repitition
During class we all had a choice to pick a topic to research, so we could talk about it to everyone next lesson I chose Control Structures Repitition. The following is what I found:
This type of control structures specify a block of one or more statements that are repeatedly executed until a condition is satisfied. These are also called iteration control structures.
There are three different ways that a set of instructions can be repeated, and each way is determined by where the decision to repeat is placed:
-at the beginning of the loop (leading decision loop)a
-at the end of the loop (trailing decision loop)
-a counted numberof times (counted loop)
1. Leading Decision Loop:
In such loops the testing of the condition is at the beginning of the loop. Examples are DO-WHILE loops. The only way to terminate the loop is to render the DO-WHILE loop false.
2. Trailing Decision Loop:
In such structures the testing of condition is done at the end of loop except that the logic to keep on repeating is same as in case of other repitition structures. REPEAT...UNTIL is an example of trailing decision loop. In trailing loops the statems ase executed at least once before the condition is tested. These loops are sued in almost all kinds of computer program e.g. to print student records, to continue taking imput until a certain limit etc.
3. Counted Loop:
These are also known as DO or FOIR loops. In such kind of repitition structures the programmer knowns in advance the exact number of loop iterations. The loop execution is controlled by an important variable called the loop index. We can now conclude that selection control structures and repitition control structures find their use in almost any application. Ising them wisely and judiciously depends on the person who is going to use these loops. Proper implementation of loop structures can reduce program complexity and cost a lot.
Some problems require a sequence of tasks to be processed repeatedly, e.g.:
-apply same processing to a set of different data items
-processing until and target point is reached
A block of statements that are to be repeated
-A condition that will determine if the loop processing should stop
-The condition is evaluated once in each iteration
-A variable that will change each time the loop is processed
A variable that will change each time the loop is processed
-tested in the condition
The following image is a visual, an example for you to see what is meant by "the loop" or repitition in a simple flow chart like this.Tuesday, August 10, 2010
Heads & Tails
Last Wednesday on August 4, we had a task called heads & tails where we had to run the program Microsoft Visual Basic, and create a new project with a form. Then we had to drag the label, button and text box from the toolbox to the form and change the name/property from BUTTON1 to CHECK and then edit the code for the label by inserting
Subscribe to:
Posts (Atom)