|
Morning Announcements & Pledge
Spring Break Week in
|
|
|
Click for Instructions
Click on the date to open the details.
Click date again to close the details.
|
| Day |
Date |
|
Discussion
|
|
09/03/07 |
|
Monday - Labor Day Holiday
--
Send your e-mail address to Mr. Clarke before school starts
asking for Extra Credit & receive Extra Credit!!!
Send your parent's/guardian's e-mail address e-mail to Mr. Clarke before school starts
and receive Extra Extra Credit!!! |
|
09/04/07 |
|
Tuesday -
OCVTS School Closed - Teacher's Preparation Day |
| 1 |
09/05/07 |
|
Wednesday - Classroom Rules - Welcome
to Computer Science |
|
- Classroom Discussion -
- Distribute student "css##" ID numbers &
passwords
- Test ID numbers & passwords by logging on
- Setup printers for use, instructions in "Lab Assignment" below
- Discuss School Rules
using Microsoft PowerPoint presentation, click link
- Lab Assignment -
- Review classroom rules
- Forms to complete & return to teacher:
- Message from Principal - student signature
- Emergency Card - student fills out
- Computer Contract - student & parent/guardian signatures
- Social Security Number - student signature
- Consent Form - parent/guardian signature
- Research "History of Computing" online, take
notes, bookmark the best sites, & be prepared to participate in
classroom discussion tomorrow
- Contact information - send "mclarke@mail.ocvts.org" an e-mail from
your e-mail address
- AIM contact name - "compSciClarke"
- Microsoft IM contact - "mrclarke@hotmail.com"
- Guidelines to Add New Printer:
- Click "Start"
- Click "Printers & other hardware"
- Identify any existing printers (HP LJ5) &
(Tektronix)
- If they both exist, simply close the
printers window, otherwise, continue:
- Click "Add a Printer" to open the Printer
Wizard
- Read the Welcome Message & Click "Next"
- Our printers are Network Printers, click
that button, & click "Next"
- Search for printers
- Click "HP LJ5" & click "Next"
- Click "Finish" to add the printer
Repeat for the "Tektronix" printer
|
| 2 |
09/06/07 |
|
Thursday - Classroom Rules, Computer
IDs, & History of Computing Science |
|
- Classroom Discussion -
- Distribute student "css##" ID numbers &
passwords
- Test ID numbers & passwords by logging on
- Setup printers for use, instructions in "Lab Assignment" below
- Discuss School Rules
using Microsoft PowerPoint presentation, click link
- Discuss The History of Computing Science
- Lab Assignment -
- Review classroom rules
- Forms to complete & return to teacher:
- Message from Principal - student signature
- Emergency Card - student fills out
- Computer Contract - student &
parent/guardian signatures
- Social Security Number - student signature
- Consent Form - parent/guardian signature
- Research "History of Software" online, take
notes, bookmark the best sites, & be prepared to participate in
classroom discussion tomorrow
- Contact information - send "mclarke@mail.ocvts.org" an e-mail from your
e-mail address
- AIM contact name - "compSciClarke"
- Microsoft IM contact - "mrclarke@hotmail.com"
|
| 3 |
09/07/07 |
|
Friday - Classroom Rules, History of
Software, Intro to Visual Basic, "vbHelloWorld" |
|
- Classroom Discussion -
- Distribute student "css##" ID numbers &
passwords
- Test ID numbers & passwords by logging on
- Setup printers for use, instructions in "Lab Assignment" below
- Discuss School Rules
using Microsoft PowerPoint presentation, click link
- Discuss History of Software:
- Computer System:
- Hardware: System Box, Keyboard, Mouse,
Monitor, Printer, etc.
- Software: Operating System &
Applications Software
- People: Requried to input data &
receive output information
- Data: Facts & Figures
- Computer System does four things:
- Input: Information put into a
communications system for transmission or into a computer system
for processing: Keyboard & Mouse
- Process: A part of a running software
program or other computing operation that does a single task
- Storage: The part of a computer that
stores information for subsequent use or retrieval: Hard Disk,
Floppy Disk, Memory Stick, Optical Disk
- Output: The information produced by a
program or process from a specific input: Monitor, Printer
- Two types of software:
- Operating Systems: Software designed to
control the hardware of a specific data-processing system in order
to allow users & application programs to make use of it
- Applications Software: a program that
gives a computer instructions that provide the user with tools to
accomplish a task
- Operating Systems:
- MS-DOS: Microsoft Disk Operating System
- Windows: A rectangular area on the screen
that displays its own file or message independently of the other
areas of the screen
- Apple OS: Apple Computer Corporation
Operating System
- Unix: An interactive time-sharing
operating system invented in 1969
- Linux: An implementation of the Unix
kernel originally written from scratch with no proprietary code
- Applications Software:
- Word Processing: The creation, input,
editing, & production of documents & texts by means of
computer systems
- Spreadsheet: An accounting or bookkeeping
program that displays data in rows & columns on a screen
- Database: Programs to ease the collection
of data arranged for ease & speed of search & retrieval
- Presentation: Software program for
creating graphic presentations with visual aids, handouts, slides,
etc
- Entertainment: Software that amuses,
pleases, or diverts
- Education: Software whereby knowledge or
skill is obtained or developed by a learning process
- Communications: Software for sending &
receiving messages
- Software Developers use Programming
Languages to create both Operating Systems & Applications
Software:
- Source Code: Before interpreting or
compiling: Code written by a programmer in a high-level language
& readable by people but not computers. Source code must be
converted to object code or machine language before a computer can
read or execute the program
- Machine Code: After interpreting or
compiling: The code produced by a compiler from the source code,
usually in the form of machine language that a computer can
execute directly
- Two main types of programming languages:
- Interpreter: A program that translates an
instruction into a machine language & executes it before
proceeding to the next instruction
- Compiler: A program that translates
another program written in a high-level language into machine
language so that it can be executed
- Basic is an interpreted language. Visual
Basic may also be compiled into executable code.
- The History of Programming
- History's Worst Software Bugs
- Introduction to Visual Basic:
- Different ways to open the VB IDE in Windows
- VB IDE - Integrated Development Environment
- Menu Options & Features
- Toolbox, Project, & Properties Windows
- Online VB6 Text: Sams Teach Yourself Visual Basic 6 in 24 Hours
- Online VB6 Text: Sams Teach Yourself Visual Basic 6 - Chapter 1 - Visual Basic at Work
- Lab Assignment -
- Review classroom rules
- Find your network home drive:
- Open Windows Explorer - click [start], click [my computer]
- Navigate to your home drive - letter "H:"
- Review the folders available
- Let me know if you have any problems
- Create a Visual Basic program "HelloWorld":
- Save your work to your "My Documents" folder
- You don't have "write" permissions to the VB6 folder
- You share the PC with another student
- You won't "overwrite" another student's work
- Another student won't "overwrite" your work
- Make a new folder in your "My Documents" called "Hello World" & save all your "Hello World" work there
- Open VB & create a new, standard.exe
- Save the form as "frmHelloWorld.frm"
- Save the project as "vbHelloWorld.vbp", both into your "My
Documents/vb" folder
- Name the Form "frmHelloWorld"
- Change the Form caption to "My First VB Program"
- Change the Form background color as desired
- Test & Save frequently Save to your "My Documents" folder & copy to your "Z:" drive
- Test & debug your program (call me for assistance)
- Add a Textbox object & name it "txtHelloWorld"
- Change the Textbox text property to "Hello World!"
- Change the Textbox font sizes as desired
- Change the Textbox size as necessary
- Change the Textbox background & foreground colors
- Test & Save frequently Save to your "My Documents" folder & copy to your "Z:" drive
- Test & debug your program (call me for assistance)
- Add a Label object & name it "lblHelloWorld"
- Change the Label caption property to "Hello World!"
- Change the Label font sizes as desired
- Change the Label size as necessary
- Change the Label background & foreground colors
- Test & Save frequently Save to your "My Documents" folder & copy to your "Z:" drive
- Test & debug your program (call me for assistance)
- Add a Command Button object & name it "cmdHelloWorld"
- Change the Command Button caption property to "Hello World!"
- Change the Command Button font sizes as desired
- Change the Command Button size as necessary
- Change the Command Button background & foreground colors (is there a foreground color?)
- Test & Save frequently Save to your "My Documents" folder & copy to your "Z:" drive
- Test & debug your program (call me for assistance)
- To open an existing VB6 project:
- Open Windows Explorer
- Navigate to the correct folder
- Double click on the ".vbp" file
- Research "Word Processing" & "Microsoft Word
Tutorial" online, take notes, bookmark the best sites, & be prepared
to participate in classroom discussion Monday
- Forms to complete & return to teacher:
- Message from Principal - student signature
- Emergency Card - student fills out
- Computer Contract - student &
parent/guardian signatures
- Social Security Number - student signature
- Consent Form - parent/guardian signature
- Contact information - send "mclarke@mail.ocvts.org" an e-mail from your
e-mail address
- AIM contact name - "compSciClarke"
- Microsoft IM contact - "mrclarke@hotmail.com"
|
|
| 4 |
09/10/07 |
|
Monday - Visual Basic Label, Textbox, & CommandButton objects, "vbAge" |
|
- Classroom Discussion -
- Some Definitions:
- Program: A sequence of instructions that a
computer can interpret & execute
- Programming: Creating a sequence of
instructions to enable the computer to do something
- Systems Analysis: The study of an activity
or procedure to determine the desired end & the most efficient
method of obtaining this end
- Writing a good program is the act of taking
a large problem & continually splitting it into smaller &
smaller sub-problems until you reach a point where each sub-problem
requires one solution & is easy to program
- Three types of sub-programs:
- sub-procedures
- sub-routines
- functions
- Syntax: The rules governing the formation of
statements in a programming language. Every programming language has
similar, but different, syntax rules
- Computer Error: the occurrence of an
incorrect result produced by a computer
- Three types of computer error:
- Syntax Error: an error in a program due to
a code that does not conform to order expected by the programming
language, detected during compiling or interpreting
- Run-Time Error: an error in arithmetic
during computer run that, detected at run time
- Logic Error: an error the programmer
makes during design of the program, the program compiles & runs
but gives incorrect results
- Computer User: A person who uses computers
for work or entertainment or communication or business
- Most users lack full understanding of how to truly use a computer
- Some users are actually afraid of the computer
- All users are either slow to learn or understand; obtuse or tend to make poor decisions or careless mistakes
- Therefore, it is up to the programmer to make the program as "idiot-proof" as humanly possible
- Users are [insert appropriate word here]!!!
- Online VB6 Text: Sams Teach Yourself Visual Basic 6 - Chapter 2 - Analyzing Visual Basic Programs
Lab Assignment -
- School Rules Quiz
- Click the link & follow the instructions
- Principal Coleman requires that each student score 100% on this quiz
- You will continue to take the quiz each day until you score 100%
- Create a Visual Basic program "Age":
- Open VB & create a new, standard.exe
- Save the form as "frmAge.frm" & save the project as "vbAge.vbp", both into your "My Documents/vb" folder
- Name the form "frmAge", change the caption to "Given your age, calculate your year of birth"
- Add a Label object, name it "lblTitle", change the caption property to "Instructions: Enter your age in the age box & click GO to calculate your year of birth"
- Add a Label object, name it "lblAge", change the caption property to "Your Current Age", this will identify what the user is to enter into the textbox
- Add a Label object, name it "lblYear", change the caption property to "Year of Birth", this will identify the answer
- Add a Textbox object, name it "txtAge", change the text property to "", this is where the user will enter his age
- Add a Label object, name it "lblAnswer", change the caption property to "", this will hold the answer
- Add a CommandButton object, name it "cmdCalculate", change the caption property to "&Calculate", change the default property to "True"
- Add a CommandButton object, name it "cmdExit", change the caption property to "e&Xit", change the cancel property to "True"
- Double-click the CommandButton object "cmdExit" & enter "End". This program instruction, executed through a user click event, will cause the program to stop running
- Double-click the CommandButton object "cmdCalculate" & enter "lblAnswer.Caption = 2007 - txtAge.Text". This program instruction, executed through a user click event, will change the Textbox object "txtYear" "Text" property to be the result of the process of subtracting the user's age, found in the Textbox object "txtAge" "Text" property, from the year 2007
- Center the instructions across the top of the form
- Change font sizes as desired
- Change background & foreground colors
- Test & Save frequently Save to your "My Documents" folder & copy to your "Z:" drive
- Test & debug your program (call me for assistance)
- - Figure out how to add objects to allow the user to enter his year of birth and display his age
|
| 5 |
09/11/07 |
|
Tuesday - Putting Code into Visual
Basic, Image Object, "vbTrafficLight" |
|
- Classroom Discussion -
- Discuss the Image object & it's properties
- Online VB6 Text: Sams Teach Yourself Visual Basic 6 - Chapter 18 - The Graphic Image Controls
Lab Assignment -
- School Rules Quiz
- Click the link & follow the instructions
- Principal Coleman requires that each student score 100% on this quiz
- You will continue to take the quiz each day until you score 100%
- Create a simple VB program to display a
traffic light image. Provide the user with three command buttons
"Stop", "Caution", & "Go". These buttons will control which of three
images will display in the form on the screen:
- Use Microsoft Paint to create three image files called "Stop.bmp", Caution.bmp", "Go.bmp"
- Alternatively, you may locate three images I found on the Internet: Look on the "Q:" drive for files named "traffic_light_green.jpg", "traffic_light_red.jpg", & "traffic_light_yellow.jpg"
- Save these to your "My Documents/vb" folder
Some ideas:
- Open VB & create a new, standard.exe
- Save the form & project to your "My Documents/vb" in a new folder called "light" as "light.frm" & "light.vbp"
- VB will NOT correctly locate any images until you close & reopen it:
- Save
- Close Visual Basic
- Use Windows Explorer (My Computer or My Documents) to navigate to your "My Documents/vb/light/" folder
- The images & VB files should all be stored in the same folder
- Open VB by double-clicking on the "light.vbp" file
- Name the form "frmLight"
- Add an image object to the center of your
form
- Name the image object "imgLight"
- Change the size to make it twice as high as
it is wide
- Add a command button.
- Name the command button "cmdRed"
- Change the caption to read "Red"
- Double-Click the "cmdRed" command button
to open the code window
- Add this line: "imgLight.Picture =
LoadPicture("traffic_light_red.jpg")"
- Save all your work & images in the same folder
- Add another command button for "Yellow",
change the name, change the caption, add the code
- Add another command button for "Green", change
the name, change the caption, add the code
- Add a label named "lblInstructions" with a
caption instructing the user to press the buttons to see the light
change
- Add another command button for "Exit"
- Name the Command Button "cmdExit"
- Change the Command Button caption to
"e&Xit"
- Change the Cancel property to "True" for
the excape key
- Double-Click the Command Button to open the
Code Window
- Add "End" after the subroutine title
cmdExit_Click() line & before the End Sub line
- Use menu bar options "Run", "Start" to test
your program
- Test & Save frequently Save to your "My Documents" folder & copy to your "Z:" drive
- Test & debug your program (call me for
assistance)
- - Figure out how to display the light image "traffic_light_all.jpg" when the program starts before the user presses any buttons
- - Figure out how add control objects to allow the user to clear or remove the traffic light totally from the screen so the user sees nothing
|
| 6 |
09/12/07 |
|
Wednesday - Visual Basic Practice with
Image, Label, Textbox, & Command Button Objects, "vbImageDisplayer",
"vbTextDemo", "vbRailDemo" |
|
- Classroom Discussion -
- Online VB6 Text: Sams Teach Yourself Visual Basic 6 - Chapter 3 - Controls and Properties
Lab Assignment -
- School Rules Quiz
- Click the link & follow the instructions
- Principal Coleman requires that each student score 100% on this quiz
- Students who have not achieved 100% will take the quiz again
- Create a simple VB program to display images two ways, normal & stretched:
- Windows contains a large number of bitmap & other graphics files
- Use a text box into which the user enters the name of a graphical image
- When the user clicks a command button, display the selected graphics file in two Image objects
Some ideas:
- Open VB & create a new, standard.exe
- Make a folder "imageDisplayer"
- Save as "frmImageDisplayer.frm" & "vbImageDisplayer.vbp" to your "My Documents/VB/imageDisplayer" folder
- Rename the Form to "frmDisplayer"
- Resize the Form to about twice as wide as it is high
- Change the caption property to read "John Doe's Famous Image Displayer", but use your name
- Add a Label object named "lblImageFileName" & change the caption property to something like "Enter File Name:"
- Add a Textbox object named "txtImageFileName" & change the text property to be blank
- Add two Image objects, the first on the left, the second on the right
- Name the first Image object "imgLeft" & the second "imgRight"
- Make both Image objects the same size & large
- Change the stretch property for imgRight to "True"
- Add a Command Button object named "cmdDisplay" & change the caption property to "&Display"
- Set this Command Button to run when the "Enter" key is pressed
- Double click the "cmdDisplay" command button & add these lines to the code window:
"imgLeft.Picture = LoadPicture(txtImageFileName.Text)"
"imgRight.Picture = LoadPicture(txtImageFileName.Text)"
Your names must match my names for this code to work
- Add a Command Button object named "cmdExit" & change the caption property to "e&Xxit"
- Set this Command Button object to run when the "Escape" key is pressed
- Write the code for the "Exit" button
- Test & Save frequently Save to your "My Documents" folder & copy to your "Z:" drive
- Test & debug your program (call me for assistance)
- SAVE FREQUENTLY
- Figure out how to make the text window a dropdown menu with all the images in a folder listed
- Create a VB program to demonstrate how text can be moved to different control instances on a form:
- When the user clicks on button 1, copy the caption from button 1 to the caption of label 1 & the text of text box 1
- When the user clicks on button 2, copy the caption from label 2 to the text of text box 2
- When the user clicks on button 3, copy the
text from text box 3 to the caption of label 3
Some ideas:
- Open VB & create a new, standard.exe
- Make a folder "textDemo"
- Save to your "My Documents/vb/textDemo" folder as
"frmTextDemo.frm" & "vbTextDemo.vbp"
- Create a form with three labels, three text
boxes, & three command buttons
- Name the form "frmTextDemo"
- Arrange the objects so they look good
- Name the form "frmTextDemo" & change the
caption to something appropriate
- Name the first text box "txt1" & change
the text to read "Text Box 1"
- Name the second text box "txt2" & change
the text to read "Text Box 2"
- Name the third text box "txt3" & change
the text to read "Text Box 3"
- Name the first label "lbl1" & change the
caption to read "Label 1"
- Name the second label "lbl2" & change the
caption to read "Label 2"
- Name the third label "lbl3" & change the
caption to read "Label 3"
- Name the first command button "cmd1" &
change the caption to read "Button 1"
- Name the second command button "cmd2" &
change the caption to read "Button 2"
- Name the third command button "cmd3" &
change the caption to read "Button 3"
- Double click the first command button &
add this code:
lbl1.Caption = cmd1.Caption
txt1.Text = cmd1.Caption
- Double click the second command button &
add this code:
txt2.Text = lbl2.Caption
- Double click the third command button &
add this code:
lbl3.Caption = txt3.Text
- Add an Exit command button, change the name
& caption. Use the "&" to make a hotkey. Make it so the
"escape" key will activate the Exit event. Double click the Exit
command button & add the code to "End" the program
- Use the techniques you learned over the
past couple of days
- Test & Save frequently Save to your "My Documents" folder & copy to your "Z:" drive
- Test & debug your program (call me for
assistance)
- What would happen if
the user changed the text in text box 2 & then clicked on command
button 2? Test your thesis
- Create a VB program to simulate a railroad
train schedule:
- Design a form that would allow the user to
choose between displaying "Morning", "Afternoon", or "Evening" train
schedules
- The information to be displayed would be
"Scheduled Departure Time", "Track Number", & "Train Status"
- Leave room to display up to five trains
Some ideas:
- Open VB & create a new, standard.exe
- Create a folder "railDemo"
- Save to your "My Documents/vb/railDemo" folder as
"frmRailDemo.frm" & "vbRailDemo.vbp"
- Name the form "frmRailDemo"
- Add a Command Button object for "Exit",
write the code, make the "Escape" key work
- Math time -- you need three labels (Time,
Track, & Status) for each of five trains:
3 x 5 = 15
so, you need to add 15 Label objects. Be sure to name each one
separately, something like: lblTime1, lblTrack1, lblStatus1
lblTime2, lblTrack2, lblStatus2
lblTime3, lblTrack3, lblStatus3
lblTime4, lblTrack4, lblStatus4
lblTime5, lblTrack5, lblStatus5
Arrange them on the form so they look good.
- Make the "Border Style" property for all
Label objects "Fixed Single" so that they look like unchangable
Textbox objects
- Write the code for the "Morning" Command
Button object:
lblTime1.Caption = "7:00 a.m."
lblTrack1.Caption = "Track 2"
lblStatus1.Caption = "On Time"
lblTime2.Caption = "7:20 a.m."
lblTrack2.Caption = "Track 1"
lblStatus2.Caption = "On Time"
lblTime3.Caption = "8:00 a.m."
lblTrack3.Caption = "Track 3"
lblStatus3.Caption = "Delayed"
lblTime4.Caption = "8:30 a.m."
lblTrack4.Caption = "Track 1"
lblStatus4.Caption = "On Time"
lblTime5.Caption = "9:00 a.m."
lblTrack5.Caption = "Track 2"
lblStatus5.Caption = "On Time"
Remember that your program will only work with my code if you
use the same object names that I have
- Write similar code for the "Afternoon" &
"Evening" Command Button objects
- Test & Save frequently Save to your "My Documents" folder & copy to your "Z:" drive
- Test & debug your program (call me for
assistance)
- - Make one of the
"Afternoon" blank & have only four trains
- Your "H:" drives should now work. You may
only access your own "H:" drive. I can access all "H:" drives. Copy
your work there so I may see it:
- Open "Windows Explorer" or "My Documents"
& navigate to "H:"
- View the folders I have created:
- C++ - for the C++ programming language projects we will create
- Grades - for me to place an Excel spreadsheet with your grades, assignments completed, & assignments due
- Java - for the Java programming language projects we will create
- OtherAssignments - for other assignments
- toBeGraded - for any project that you wish me to grade - NOTE: I will empty this folder after I grade your work
- VB - for the Visual Basic programming language projects we will create
- Every
day, after your work is complete, copy the most recent folders & files to the
proper folder on the "H:" drive
- If you want me to grade an assignments, also copy it to "toBeGraded"
|
| 7 |
09/13/07 |
|
Thursday - OCVTS School Closed - Rosh Hashanah |
|
- Classroom Discussion -
- Parental/Guardian signed forms due on Monday: no computer contract = no computer
use
- Discuss Chapter 5 from Free-Ed.Net on Visual Basic,
"Lesson 5 - Putting Code into VB"
- Discuss:
- Lab Assignment -
- School Rules Quiz
- Click the link & follow the instructions
- Principal Coleman requires that each student score 100% on this quiz
- You will continue to take the quiz each day until you score 100%
- Create a simple VB program to test data type
mixups:
- Assign a real number to an integer variable
& display the integer variable in a label caption
- Assign an integer number to a real variable
& display the integer variable in a label caption
Some
ideas:
- Open VB & create a new, standard.exe
- Save the form & project to your "My
Documents/vb" folder as "frmVariableDemo.frm" & "vbVariableDemo"
- Name the form
- Add code for two global variables at the
top of the code window:
Dim sngNum As Single
Dim intNum As Integer
- Add a command button & code & "cancel"
for exit
- Add a text box for input "txtInput"
- Add a label for output "lblOutput"
- Add a command button & code for
RealInteger
intNum = txtInput.Text
lblOutput.Caption = intNum
- Test with a real number, like "2.5". Is the
output real or integer?
- Add a command button & code for
IntegerReal
sngNum = txtInput.Text
lblOutput.Caption = sngNum
- Test with an integer number, like "7". Is
the output real or integer?
- Test & Save frequently Save to your "My Documents" folder & copy to your "Z:" drive
- Test & debug your program (call me for
assistance)
- What happens if you
enter a word or a date?
- Create a VB program to perform common
distance conversions:
- Inches to Centimeters
- Centimeters to Inches
- Feet to Meters
- Meters to Feet
- Miles to Kilometers
- Kilometers to Miles
For your
conversion numbers:
- 1 inch = 2.54 centimeters
- 1 centimeter = 0.4 inches
- 1 foot = 0.305 meters
- 1 meter = 3.28 feet
- 1 mile = 1.6 kilometers
- 1 kilometer = 0.625 miles
Some
ideas:
- Open VB & create a new, standard.exe
- Save the form & project to your "My
Documents/vb" folder as "frmDistanceConverter.frm" &
"vbDistanceConverter"
- Add a textbox for input
- Add a label for output
- Add instructions to the user
- Add & name a command button for each
conversion
- Here's the general steps for each button:
- Assign the input text into a variable
- Calculate the answer
- Assign the answer to the output label
caption
- For example, Inches to Centimeters, if
you use these variable names:
dblInput = txtInput.text
dblOutput = dblInput * 2.54
lblOutput.caption = dblOutput
- Add a command button & code & "cancel"
for exit
- Test & Save frequently Save to your "My Documents" folder & copy to your "Z:" drive
- Test & debug your program (call me for
assistance). Use numbers that are easy to confirm. For example:
10 inches = 25.4 centimeter
10 centimeters = 4.0 inches
- Add some other useful
distance conversions
|
| 8 |
09/14/07 |
|
Friday -
"vbTemperatureConverter" |
|
- Classroom Discussion -
- Parental/Guardian signed forms due on Monday: no computer contract = no computer
use
- Next week my AM class is assigned the pledge
& morning announcements - any volunteers?
- Discuss:
- Global Variables - Declared at the top of
the program, usable by any part of the program
- Local Variables - Declared inside a
sub-routine, usable by ONLY that sub-routine
- OPTION EXPLICIT - Written as the first line
of the program, requires the programmer to correctly declare &
spell any & all variables -- a great programming technique
- Variable Naming Convention:
- Must start with a letter
- May contain letters & numbers
- May NOT contain special characters
- May contain underscore "_"
- Use the 3-letter prefix patterns:
- int for integer
- sng for single
- dbl for double
- str for string
- bln for boolean
- dtm for date
- Should make sense to another programmer:
- use intAge instead of a
- use sngPayRate instead of pr
- use dblLightSpeed instead of ls
- use strFirstName instead of fn
- use blnIsActiveMember instead of iam
- use dtmBirthDate instead of bd
- Variable Declaration Syntax - "Dim VarName
As DataType" - Examples:
- Dim intAge As Integer
- Dim sngPayRate As Single
- Dim dblLightSpeed As Double
- Dim strFirstName As String
- Dim blnIsActiveMember As Boolean
- Dim dtmBirthDate As Date
- Review before Quiz - NOW is the time to
ask your questions
- Lab Assignment -
- Create a VB program to perform common
temperature conversions:
- Fahrenheight to Centigrade
- Centigrade to Fahrenheight
For your
conversion numbers:
- Fahrenheight temperature is 9/5ths of the
Centigrade temperature plus 32 (do the plus 32 last)
- Centigrade temperature is 5/9ths of the
Fahrenheight temperature minus 32 (do the minus 32 first)
- (If you can't figure out the conversion,
watch the board, I'll do some examples)
Some ideas:
- Open VB & create a new, standard.exe
- Save the form & project to your "My
Documents/vb" folder as "frmTemperatureConverter.frm" &
"vbTemperatureConverter"
- Add a textbox for input
- Add a label for output
- Add instructions to the user
- Add variables at the top of the program
- Add & name a command button for each
conversion
- Here's the general steps for each button:
- Assign the input text into a properly
named variable of the proper data type
- Calculate the answer & assign the
answer to the output label caption
- Add a command button & code & "cancel"
for exit
- Test & Save frequently Save to your "My Documents" folder & copy to your "Z:" drive
- Test & debug your program (call me for
assistance). Use numbers that are easy to confirm. For example:
68o F = 20o C & 20o C = 68o
F 77o F =
25o C & 25o C = 77o
F 86o F =
30o C & 30o C = 86o
F
- Add some other useful
temperature conversions, like Kelvin
- Complete any unfinished labs
|
|
| 9 |
09/17/07 |
|
Monday - Pledge & Announcements, Visual Basic Quiz 1, VB Input/Output, "vbTemperatureConverter2" |
|
- Classroom Discussion -
- One AM student needed as volunteer to assist with the morning pledge & announcements
- Parental/Guardian signed forms due TODAY: no computer contract = no computer use
- Online VB6 Text: Sams Teach Yourself Visual Basic 6 - Chapter 4 - Examining Labels, Buttons, and Text Boxes
- Online VB6 Text: Sams Teach Yourself Visual Basic 6 - Chapter 5 - Putting Code into Visual Basic
- Online VB6 Text: Sams Teach Yourself Visual Basic 6 - Chapter 6 - Message and Input Boxes
- VB Code Comments or Remarks - Remarks help both you & other programmers who might modify & update your Visual Basic applications in the future. Remarks offer descriptive messages that explain in English (or whatever language you prefer) what's going on in the program's event procedures:
REM This is one example of a remark
' This an example of a comment
Dim intAge As Integer REM This is a third example of a remark
intAge = 17 ' & this is a fourth example of a comment
Programmers often add remarks to their programs for the following purposes:
- To state the programmer's name & the date that the program was written
- To describe in the general section the overall goal of the program (the general section appears before all of a procedure's procedures & is the location Hour 5, "Putting Code into Visual Basic," described when it talked about declaring global variables)
- To describe at the top of every procedure the overall goal of that procedure
- To explain tricky or difficult statements so that others who modify the program later can understand the lines of code without having to decipher cryptic code
- VB Output - MsgBox() - Instructions or output to the user, returns a number that tells which button the user has clicked:
- Do lab 1
- VB Input - InputBox - Another way to get input, returns a string value that holds the answer typed by the user:
- Syntax:
strVariable = InputBox( strPrompt [, [strTitle] [, strDefault] [, intXpos, intYpos]]])
- strPrompt - the content of the message to the user
- strTitle - optional message box title bar text
- strDefault - optional default input so that the user can just hit [OKAY]
- intXpos - number of twips from the left side
- intYpos - number of twips from the top
- Do lab 2
- Lab Assignment -
- Visual Basic Quiz 1
- Modify your "vbTemperatureConverter.vbp" program to use a MsgBox:
- Use a MsgBox to tell the user goodbye on exit
Some ideas:
- Use windows explorer & navigate to where your program "vbTemperatureConverter.vbp" is saved & open it
- Add a new global variable at the top:
Dim intMsgRes As Integer
- View the form & double click command button exit
- Add VB code for a MsgBox before the "End" command:
intMsgRes = MsgBox("Goodbye")
- Test it to see how it works
- Modify the VB msgbox code to see how some of the icons & buttons & title work:
intMsgRes = MsgBox("Goodbye", vbInformation, "Exit Message")
or
intMsgRes = MsgBox("Goodbye", vbOKOnly, "Son of a Gun")
or
intMsgRes = MsgBox("Goodbye", vbExclamation + vbonly, "This is Fantastic")
or
intMsgRes = MsgBox("Goodbye", vbQuestion + vbYesNo, "Or maybe Tanfastic")
or
intMsgRes = MsgBox("Goodbye", vbCritical + vbAbortRetryIgnore, "I'm gettin' this")
- Modify your "vbTemperatureConverter.vbp" program to use an InputBox:
- Use an InputBox to allow the user to confirm the temperature
- Echo the user input from the textbox as the default in an InputBox & ask the user it this is accurate
Some ideas:
- View the form & double click command button FahrToCent
- Modify VB code for an InputBox after assigning the textbox to a variable but before processing the variable:
sngFahr = txtInput.Text
sngFahr = InputBox("Convert this temperature?", , sngFahr) ' confirm temperature to be converted
txtInput.Text = sngFahr ' put the inputbox temperature into the textbox in case the user has changed it
sngCent = (sngFahr - 32) * 5 / 9
lblOutput.Caption = sngCent
- Test it to see how it works
- Modify the VB msgbox code to see how the title works:
sngFahr = InputBox("Convert this temperature?", "Temperature Confirmation, sngFahr)
- Do similarly for Centigrade to Fahrenheit
- Test & Save frequently Save to your "My Documents" folder & copy to your "Z:" drive
- Add a confirm exit MsgBox to all of your VB programs
|
| 10 |
09/18/07 |
|
Tuesday - Pledge &Announcements, VB IF THEN Statement, "vbSalary", "vbGrades" |
|
- Classroom Discussion -
- One AM student needed as volunteer to assist with the morning pledge & announcements
- Parental/Guardian signed forms due: no computer contract = no computer use
- Vocabulary:
- Three types of statements in every programming language:
- Sequential - Following of one after another
- Decision - The act of reaching a conclusion or making up one's mind
- Iteration - To perform again; repeat
- Algebra - A branch of mathematics in which symbols, usually letters of the alphabet, represent numbers or members of a specified set & are used to represent quantities & to express general relationships that hold for all members of the set
- George Boole (1815-1864) - British mathematician & logician who developed a calculus of symbolic logic
- Boolean - Of or relating to a logical combinatorial system treating variables, such as propositions & computer logic elements, through the operators AND, OR, NOT, & XOR
- Boolean Algebra - An algebra in which elements have one of two values & the algebraic operations defined on the set are logical OR, a type of addition, & logical AND, a type of multiplication
- Online VB6 Text: Sams Teach Yourself Visual Basic 6 - Chapter 7 - Making Decisions
- Review Arithmetic Operators & Order of Operations (PEMDAS):
- ( ) Parenthesis
- ^ Exponentiation
- * Multiply
- / Divide
- + Add
- - Subtract
- Review String Arithmetic Operator:
- Comparison Operators:
- > Greater Than
- < Less Than
- = Equal To
- >= Greater Than or Equal To
- <= Less Than or Equal To
- <> Not Equal To
- Comparison Rules:
- Returns True or False
- Resulting return may be stored in a Boolean variable
- Compare only two objects at a time
- Both sides must be the same data type
- Do not compare non-integer numbers for equality
- To compare three or more objects, compare pairs using Boolean operators & Boolean Algebra
- Comparison Examples:
- lblSales.Caption > Goal
- Pay < 2000.00
- Age = Limit
- FirstName >= "Mike"
- Num <= lblAmt.Caption
- txtAns.Text <> "Yes"
- The VB IF THEN Statement:
- Lab Assignment -
- Create a new VB program to process Salary:
- Receive hours worked from the user
- Receive pay rate from the user
- Calculate & display gross pay
- Calculate & display taxes
- Calculate & display net pay
Program Logic:
- User will enter hours worked & pay rate, so you need to save this data to variables
- Gross pay is calculated as hours worked times pay rate
- Taxes is calculated as 20% of gross pay
- Net pay is the result of subtracting taxes from gross pay
Some ideas:
- Open VB & create a new, standard.exe
- Save the form & project to your "My Documents/vb" folder as "frmSalary.frm" & "vbSalary.vbp"
- Create variables at the top:
Option Explicit
Dim sngHoursWorked As Single
Dim sngPayRate As Single
Dim sngGrossPay As Single
Dim sngTaxes As Single
Dim sngNetPay As Single
Dim intMsgRes As Integer
Dim strResults As String
- Add a command button to exit, set the cancel property to true so the escape key works, add the code to end
- Modify the exit button to use a MsgBox to allow the user to confirm upon exit:
intMsgRes = MsgBox("Really Exit?", vbQuestion + vbYesNo, "Confirm Exit")
If intMsgRes = vbYes Then
End ' exit on user click yes
End If
- Add a command button to go, set the default property to true so the enter key works, add the code:
- Receive sngHoursWorked & sngPayRate from the user using InputBoxes:
sngHoursWorked = InputBox("Enter Hours Worked", "Hours Worked", 30)
sngPayRate = InputBox("Enter Pay Rate", "Pay Rate", 10)
- Calculate gross pay, taxes, & net pay:
sngGrossPay = sngHoursWorked * sngPayRate
sngTaxes = sngGrossPay * .2
sngNetPay = sngGrossPay - sngTaxes
- Display results to user using a message box:
strResults = "Hours Worked: " & sngHoursWorked & vbCrLf
strResults = strResults & "Pay Rate: " & sngPayRate & vbCrLf
strResults = strResults & "Gross Pay: " & sngGrossPay & vbCrLf
strResults = strResults & "Taxes: " & sngTaxes & vbCrLf
strResults = strResults & "Net Pay: " & sngNetPay
intMsgRes = MsgBox(strResults, vbOKOnly, "Salary")
- Test with these numbers. If you enter hours & rate, your resulting gross, taxes, & net should be the same as mine:
| hours |
rate |
gross |
taxes |
net |
| 30 |
10 |
300 |
60 |
240 |
| 40 |
10 |
400 |
80 |
320 |
| 50 |
10 |
500 |
100 |
400 |
- Test & Save frequently Save to your "My Documents" folder & copy to your "Z:" drive
- What can you think of to do to make this program better?
- Create a new VB program to determine a letter grade given a numberical grade. Consider:
- Read a number grade & display the appropriate letter grade:
| Number Grade |
Letter Grade |
| 93-100 |
A |
| 85-92 |
B |
| 75-84 |
C |
| 65-74 |
D |
| 0-64 |
F |
Some ideas:
- Open VB & create a new, standard.exe
- Save the form & project to your "My Documents/vb" folder as "frmGrades.frm" & "vbGrades.vbp"
- What variables do you need?
- Is the number grade variable integer or single?
- What data type is the letter grade variable?
- How will you receive your input (number grade)?
- How will you code the decision the computer needs to make?
- Is the order in which you test number grade important?
- How will you display the result to the user?
- Test all possibilities: 100, 95, 85, 75, 65, 55, 0
- Test & Save frequently Save to your "My Documents" folder & copy to your "Z:" drive
- What can you think of to do to make this program better?
|
| 11 |
09/19/07 |
|
Wednesday - Pledge & Announcements, "vbTicTacToe" |
|
- Classroom Discussion -
- One AM student needed as volunteer to assist with the morning pledge & announcements
- Parental/Guardian signed forms due: no computer contract = no computer use
- Review Online VB6 Text: Sams Teach Yourself Visual Basic 6 - Chapter 7 - Making Decisions
- Visual Basic Techniques:
- Line Object - demo on board, properties
- Keeping track of the next player - demo on board
- Change a command button caption by clicking on the button
- Prevent a second click on a button that's already been clicked once
- Check for a winner
- After finding a winner, prevent any more clicks
- Use a Reset command button to restart the game
- Lab Assignment -
- Job Seeking Skills Pre-Test. Click the link & follow the instructions. You get one shot at this one, but it doesn't count. You'll take it again in June to see how much you've learned about job seeking
- Create a Visual Basic game of Tic Tac Toe:
- Open VB & create a new, standard.exe
- Save the form & project to your "My Documents/vb" folder as "frmTicTacToe.frm" & "vbTicTacToe.vbp"
- Design the form:
- Exit button, write & test the code
- Nine command buttons arranged 3 by 3 for the game board named:
| cmdTopLeft |
cmdTopCenter |
cmdTopRight |
| cmdMidLeft |
cmdMidCenter |
cmdMidRight |
| cmdBotLeft |
cmdBotCenter |
cmdBotRight |
- Place line objects between the buttons for visual effect
- A label with general instructions
- Another label to display which player plays next
- Remember to use
Option Explicit as the first line in your code window
- Test & Save frequently Save to your "My Documents" folder & copy to your "Z:" drive
- Declare Variables:
Dim intMesRet As Integer ' which button the user clicked on in a message window
Dim strNextPlay As String ' either "X" or "O" to indicate which player plays next
Dim blnWinner As Boolean ' prevent further play if you have a winner
- Code for Form_Load()
- Code for cmdTopLeft:
- Code for cmdTopCenter:
- Copy the code from cmdTopLeft to cmdTopCenter
- Change all references from topleft to topcenter
- Test it
- Repeat copy & change for each of the other seven buttons, testing each time
- Consider how to check for a winner -- how many ways can you score three in a row?
- Top row horizontal
- Middle row horizontal
- Bottom row horizontal
- Left column vertical
- Center column vertical
- Right column vertical
- Top left to bottom right diagonal
- Top right to bottom left diagonal
- Code the top-row-horizontal check-for-winner & announce a winner & test it
- Copy & paste the top-row-horizontal check-for-winner & change for middle-row-horizontal
- Copy & paste & change for the other row & column & diagonal
- Test & Save frequently Save to your "My Documents" folder & copy to your "Z:" drive
- Keep track of & display how many wins for "X" & how many wins for "O"
- Create a [Reset] command button & write the code
- Tell the user if there is a tie (all buttons filled but no winners)
|
| 12 |
09/20/07 |
|
Thursday - Pledge & Announcements, Microsoft PowerPoint, Math |
|
- Classroom Discussion -
- One AM student needed as volunteer to assist with the morning pledge & announcements
- Parental/Guardian signed forms due: no computer contract = no computer use
- Parts of a computer according to build-your-own-computers.com
- Computer Case
- Motherboard
- CPU
- Memory (RAM)
- Monitor
- Hard drives & Floppy Drives
- CD & DVD Drives
- Video Card
- Keyboard & Mouse
- Sound
- NIC
- Microsoft PowerPoint Online Tutorial from Microsoft
- Math with Ms. Verde
- Lab Assignment -
- Microsoft PowerPoint pratice
- Create a Microsoft PowerPoint presentation on "How to Build Your Own Computer"
- Open Microsoft PowerPoint
- Create a new blank presentation
- Choose a new design (click the menu bar button or F[o]rmat, Slide [D]esign
- Save the presentation to the "My Documents" folder
- Use the filename "css##-Build Your Own Computer.ppt" (use your own css number)
- Title the presentation "How to Build Your Own Computer"
- Add your name & Computer Science as the sub-title on the first page
- Insert a new page
- Title the new page "The Computer Case"
- Add some simple text describing the computer case - perform a Google search if you don't know how a part works
- Locate & copy an image of the computer case (you don't need to save to "My Documents")
- Paste the copied image to the new page
- Repeat for each of the computer parts listed above
- Insert a "Conclusions" or "Summary" or "Questions" or "Sources" page at the end
- Save frequently
- Run the slideshow to see how your presentation looks
- I will copy these presentations to your "H:" drive when we get back to our regular classroom
|
| 13 |
09/21/07 |
|
Friday - Pledge & Announcements, Grade Print Sheet, Finish Tic Tac Toe, VB IF THEN ELSE Statement, "vbSalary2", VB Nested IF THEN ELSE Statement, "vbGrades2" |
|
- Classroom Discussion -
- One AM student needed as volunteer to assist with the morning pledge & announcements
- Parental/Guardian signed forms due: no computer contract = no computer use
- Review Online VB6 Text: Sams Teach Yourself Visual Basic 6 - Chapter 7 - Making Decisions
- Review Arithmetic Operators, String Aritmetic Operator, Comparison Operators, Comparison Rules
- The VB IF THEN ELSE Statement:
- Review Online VB6 Text: Sams Teach Yourself Visual Basic 6 - Chapter 7 - Making Decisions
- Nested VB IF THEN ELSE Statements:
- Lab Assignment -
- Modify your vbSalary program to work with overtime. Program Logic:
- Hours worked up to & including 40 is normal time & receives normal pay
- Any hours worked over 40 is considered overtime & receives 1.5 times pay rate
- Only hours worked over 40 gets time & a half & this is added to normal 40 hour pay
- The computer must make a decision - use an IF THEN ELSE statement
Some ideas:
- Modify the command button where the work is done:
If sngHoursWorked <= 40 Then
sngGrossPay = sngHoursWorked * sngPayRate
Else
sngGrossPay = (40 * sngPayRate) + ((sngHoursWorked - 40) * sngPayRate * 1.5)
End If
- Test all possibilities: 30 hours, 40 hours, 50 hours
- Test with these numbers. If you enter hours & rate, your resulting gross, taxes, & net should be the same as mine:
| hours |
rate |
gross |
taxes |
net |
| 30 |
10 |
300 |
60 |
240 |
| 40 |
10 |
400 |
80 |
320 |
| 50 |
10 |
550 |
110 |
440 |
- Test & Save frequently Save to your "My Documents" folder & copy to your "Z:" drive
- Hours over 60 get double time
- Modify your vbGrades program to use nested IF THEN ELSE statements. Program Logic:
- Perform nested testing to determine where the number grade is
Some ideas:
- Modify the command button where the work is done:
intNumGrade = txtInput.Text
If intNumGrade >= 93 Then
strLetGrade = "A"
ElseIf intNumGrade >= 85 Then
strLetGrade = "B"
ElseIf intNumGrade >= 75 Then
strLetGrade = "C"
ElseIf intNumGrade >= 65 Then
strLetGrade = "D"
Else
strLetGrade = "F"
End If
lblOutput.Caption = strLetGrade
- Add a comment as to how well the student is doing (A=Fantastic, B=Good Job, etc.)
|
|
| 14 |
09/24/07 |
|
Monday - Technology Boolean Logic, VB SELECT CASE Statement, "vbGrades" |
|
- Classroom Discussion -
- Definitions, from Dictionary.com:
- Algebra - A branch of mathematics in which symbols, usually letters of the alphabet, represent numbers or members of a specified set & are used to represent quantities & to express general relationships that hold for all members of the set
- Origins of the word Algebra:
- George Boole (1815-1864) - British mathematician & logician who developed a calculus of symbolic logic:
- Boolean - Of or relating to a logical combinatorial system treating variables, such as propositions & computer logic elements, through the operators AND, OR, NOT, & XOR:
- Boolean Algebra - An algebra in which elements have one of two values & the algebraic operations defined on the set are logical OR, a type of addition, & logical AND, a type of multiplication:
- John Venn (1834-1923) - English logician who introduced Venn diagrams:
- Venn Diagram - A diagram using circles to represent sets, with the position & overlap of the circles indicating the relationships between the sets
- Links:
- Glencoe Boolean Door Locks - Great example of how Boolean works
- IguanaLabs Boolean Truth Tables
- The VB SELECT CASE Statement:
- Simpler way to write a multi-decision, multi-choice process
- Syntax - one value each:
Select Case Expression1
Case value1
One or more Visual Basic statements A
Case value2
One or more Visual Basic statements B
[Case value3
One or more Visual Basic statements C]
[Case Else
One or more Visual Basic statements D]
End Select
- Expression1 is a variable
- IF expression1 is equal to value1 THEN statements A are performed
- IF expression1 is equal to value2 THEN statements B are performed
- IF expression1 is equal to value3 THEN statements C are performed
- IF expression1 is equal to none of the values THEN statements D are performed
- Alternate Syntax - uses < & > symbols:
Select Case Expression2
Case Is Relation1:
One or more Visual Basic statements A
Case Is Relation2:
One or more Visual Basic statements B
[Case Is Relation3:
One or more Visual Basic statements C]
[Case Else:
One or more Visual Basic statements D]
End Select
- IF expression2 is greater or less than (depending on the symbol used) relation1 THEN statements A are performed
- IF expression2 is greater or less than (depending on the symbol used) relation2 THEN statements B are performed
- IF expression2 is greater or less than (depending on the symbol used) relation3 THEN statements C are performed
- IF expression2 is greater or less than (depending on the symbol used) none of the relations THEN statements D are performed
- Alternate Syntax - give a range start to end:
Select Case Expression3
Case value1 To value2:
One or more Visual Basic statements A
Case value3 To value4:
One or more Visual Basic statements B
[Case value5 To value6:
One or more Visual Basic statements C]
[Case Else:
One or more Visual Basic statements D]
End Select
- IF expression3 is between start value1 & end value2 THEN statements A are performed
- IF expression3 is between start value3 & end value4 THEN statements B are performed
- IF expression3 is between start value5 & end value6 THEN statements C are performed
- IF expression3 is between none of the values THEN statements D are performed
- SELECT CASE, used correctly, is a very powerful & easy-to-use programming technique
- SELECT CASE can be much easier to write & understand than complex nested IF THEN ELSE statements
- Lab Assignment -
- Create the "vbGrades" program as defined on Tuesday & Friday last week
|
| 15 |
09/25/07 |
|
Tuesday - Math Time-Value-of-Money, VB Built-in-Formulas, "vbMoney" part I |
|
- Classroom Discussion -
- Time Value of Money - Is it better to have money now rather than later?
- Time Value of Money - VB Formulas:
- Visual Basic Pre-Defined Built-In Functions:
- IsNumeric("string") ' returns True if string is only numbers
- Visual Basic Pre-Defined Built-In Functions:
- Lab Assignment -
- Create a VB program to view time-value of money Future-Value calculations:
I want to put aside money now & see how it'll grow over time
- Future Value of Savings
- You need to know four things:
- Value - How much you're starting with
- Deposit - How much you'll deposit every month
- Interest Rate - How much the bank pays you to save your money with them
- Length of Term - How long you're planning to save
For your calculations:
- Use the VB IDE to help you place the variables in the function
Some ideas:
- Open VB & create a new, standard.exe
- Save the form & project to your "My Documents/vb" folder as "frmMoney.frm" & "vbMoney.vbp"
- Add textboxes for input:
- txtValue
- txtDeposit
- txtRate
- txtTerm
- Add a label for output:
- lblOutput
- Add labels to identify all textboxes
- Add instructions to the user
- Add variables at the top of the program:
- dblValue
- dblDeposit
- dblRate
- dblTerm
- dblFuture
- intMesRet
- Add command buttons:
- Future Value
- Exit
- Steps for the Calculate Future Value button:
- Test each input textbox for numeric & then convert to data type double (use "CDbl(txtInput.text)") of the textbox to the variable
- Assign the result of the predefined Visual Basic function "FV" to the output variable
- Display the variable, formatted as currency, on the output label
- Add a command button & code & "cancel" for exit
- Test & Save frequently Save to your "My Documents" folder & copy to your "Z:" drive
- Test & debug your program (call me for assistance). Use numbers that are easy to confirm. For example:
| Starting Value Only, No Deposits |
| Value |
Deposit |
Rate |
Term |
Total Deposits |
Value |
| 100 |
0 |
5 |
1 |
$100 |
$105.12 |
| 100 |
0 |
10 |
1 |
$100 |
$110.47 |
| 100 |
0 |
10 |
10 |
$100 |
$270.70 |
| 1000 |
0 |
10 |
40 |
$1000 |
$53,70.67 |
| Starting Value With Deposits |
| Value |
Deposit |
Rate |
Term |
Total Deposits |
Value |
| 100 |
10 |
5 |
1 |
$220 |
$227.90 |
| 100 |
10 |
10 |
1 |
$220 |
$236.13 |
| 100 |
10 |
10 |
10 |
$1,300 |
$2,319.15 |
| 1000 |
100 |
10 |
40 |
$49,000 |
$686,10.86 |
- Calculate & display the extra money gained through interest over time
|
| 16 |
09/26/07 |
|
Wednesday - Career Job-Seeking-Skills pre-test, "vbMoney" part II |
|
- Classroom Discussion -
- Flyers on Board
- Ocean County College registrations form due Monday, October 1st
- Career - Job Hunting
- Time-Value of Money - the Rule of 72
- Visual Basic Pre-Defined Built-In Functions:
- IsNumeric("string") ' returns True if string is only numbers
- Visual Basic Pre-Defined Built-In Functions:
- Lab Assignment -
- Modify the time-value of money VB program to view Payment calculations:
I want to see how much I have to pay each month to pay off a loan
- How much will you need to save each month to reach a certain value
- You need to know three things:
- Value - How much you have to pay off at the end of the term
- Interest Rate - How much the bank is charging you for you to borrow their money
- Length of Term - How long you have to pay
For your calculations:
- Use the VB IDE to help you place the variables in the function
Some ideas:
- Modify your existing "money.vbp" to add a new process
- Add a new command button:
- Calculate Payment
- Steps for the Calculate Future Value button:
- Test each input textbox for numeric & then convert to data type double (use "CDbl(txtInput.text)") of the textbox to the variable
- Assign the result of the predefined Visual Basic function "PMT" to the output variable
- Display the variable, formatted as currency, on the output label
- Add a command button & code & "cancel" for exit
- Test & Save frequently Save to your "My Documents" folder & copy to your "Z:" drive
- Test & debug your program (call me for assistance). Use numbers that are easy to confirm. For example:
| Final |
Rate |
Term |
Value |
| 1000 |
3 |
3 |
$26.58 |
| 10000 |
3 |
5 |
$154.69 |
| 20900 |
2.99 |
5 |
$323.38 |
| 25000 |
3 |
5 |
$386.75 |
- Calculate & display the true cost of the loan
|
| 17 |
09/27/07 |
|
Thursday - English 2nd-Year Students visit with Ms. Gerick, "vbDates" |
|
- Classroom Discussion -
- Ocean County College registrations form due Monday, October 1st
- English: Second-year students will visit with Ms. Gerick to work on a portfolio
- Vocabulary:
- Data Validation: the process of ensuring that a program operates on clean, correct and useful data (wikipedia.org)
- Visual Basic Pre-Defined Built-In Functions:
- Date ' returns today's date as data type date
- IsDate("string date") ' returns True if the string date is a valid date
- CVDate("string date") ' returns the string date as data type date
- Visual Basic Pre-Defined Built-In Functions:
- Lab Assignment -
- Create a Visual Basic program called "dates" to calculate how many days are between two user-entered dates
- How will you allow the user to enter two dates?
- What data type will you use to store the two user-entered dates?
- What data type will you use to store the difference between the two dates?
- How will you display the answer to the user?
For your calculations:
- Supply today's date for the user to either accept or change
Some ideas:
- Open VB & create a new, standard.exe
- Save the form & project to your "My Documents/vb" folder as "dates.frm" & "dates.vbp"
- Add 2 textbox for input & a label for output:
- txtDate1
- txtDate2
- lblOutput
- Add labels to identify the textbox
- Add variables at the top of the program:
- intMesRet
- dte1
- dte2
- intDaysBetween
- Add command buttons:
- cmdGo
- cmdExit
- Program & test the Exit command button
- Steps for the Go command button:
- Use "IsDate()" to ensure that the user entered a valid txtDate1.text
- Else display an appropriate error message & set the focus to txtDate1
- Use "IsDate()" to ensure that the user entered a valid txtDate2.text
- Else display an appropriate error message & set the focus to txtDate2
- Continue only if both textbox are valid dates
- Convert txtDate1.text to data type date & store in variable dte1
- Convert txtDate2.text to data type date & store in variable dte2
- Calculate the difference between the two date variables & store in variable intDaysBetween
- Display variable intDaysBetween to the user on lblOutput.caption with an appropriate message
- Test & Save frequently Save to your "My Documents" folder & copy to your "Z:" drive
- Always display a positive number of days between, never a negative, for example: 9/05-9/25 = -18
|
| 18 |
09/28/07 |
|
Friday - SkillsUSA, Visual Basic Quiz 3, "vbMadLibs" |
|
- Classroom Discussion -
- Ocean County College registrations form due Monday, October 1st
- Skills USA
- Technology Vocabulary:
- Concatenate - To arrange (strings of characters) into a chained list
- Mad Libs - wikipedia.org - definition
- penguinGroup.com - Mad Libs online game & instructions
- The concatenate symbol is " & "
- Examples:
dim strWord1 as String
dim strWord2 as String
dim strOutput as String
strword1 = "large"
strword2 = "house"
strOutput = "Hello " & "World!"
strOutput = "Hello " & strWord1 & " World!"
strOutput = "Hello " & strWord1 & " " & strWord2 & " World!"
strOutput = "Hello " & txtFirstName.Text & " " & txtLastName.Text & _
", Welcome to my " & strWord1 & " " & strWord2
VB Syntax to add to an existing string variable:
strOutput = "First line of text" & VbCrLf
strOutput = strOutput & "Second line of text" & VbCrLf
strOutput = strOutput & "Third line of text" & VbCrLf
strOutput = strOutput & "Fourth line of text" & VbCrLf
Here's how the above code will display:
First line of text
Second line of text
Third line of text
Fourth line of text
- Lab Assignment -
- Create a Visual Basic program called "madLibs" to play the famous game on computer
Use between five (5) & ten (10) user-supplied words:
- What story will you chose? Will you make one up? Will you borrow one from the internet?
- What words will you replace in the story with user-supplied words?
- How will the user enter the words to be replaced?
- What variables will you need? What data types?
- How will you display the changed story to the user?
Some ideas:
- Open VB & create a new, standard.exe
- Save the form & project to your "My Documents/vb" folder as "madLibs.frm" & "madLibs.vbp"
- Add up to 10 textbox for input
- Use a textbox for output so the user may highlight & copy the madlibs story
- Name each input textbox & output textbox appropriately
- Set the output textbox properties "MultiLine = True" & "ScrollBars = 2 - Vertical"
- Add labels to identify what the user needs to type into each textbox
- Add any variables at the top of the program & be sure to use Option Explicit
- Add & program & test the EXIT command button
- Add & program a GO command button:
- Sequentially test each input textbox for not blank
- It any input textbox is blank, use a msgbox to tell the user & set the focus to that input textbox
- Use concatenation to build the story output variable
- Mix the words the user has entered into the textboxes with the existing story
- Display the story output variable onto the output textbox
- Test & Save frequently Save to your "My Documents" folder & copy to your "Z:" drive
- Let the user choose from more than one story & use the same user-supplied words
|
|
| 19 |
10/01/07 |
|
Monday - VB Loops, "vbNumberLoops" |
|
- Classroom Discussion -
- Definitions:
- Loop - A sequence of instructions that repeats either a specified number of times or until a particular condition is met
- Iterate - To say or perform again
- Iteration - The process of repeating a set of instructions a specified number of times or until a specific result is achieved
- Infinite Loop - One that never terminates
- Sentinel - One that keeps guard
- Sentinel Variable - A variable that changes to determine when a program loop stops looping
- Usage:
- Works with comparison tests, just like decisions
- The six comparision operators ( < > = <= >= <> ) work just the same
- The block of code continues being interpreted & executed as long as the comparison returns a TRUE result
- When the comparison returns a FALSE result, the loop ends & the program continues with the first statement after the LOOP statement
- It's possible to have a loop where the comparison test returns a FALSE the first time it's tested - the block of statements will never be executed
- It's also possible to have a loop where the comparison test never changes to return a FALSE & therefor never exits
- A never-ending-loop is one where the sentinel variable never changes so that the comparison never returns a FALSE condition & the loop never ends
- Rules: STP
- Sentinel Variable - The variable that will be tested as part of the comparison
- Start - Initialize the sentinel variable to some value before the start of the loop
- Test - The comparison test will determine if the block of statements in the loop execute
- Change - Modify the value of the sentinel variable inside the loop block
- Warnings:
SAVE YOUR PROGRAM BEFORE TESTING A LOOP
- You'll get an infinite loop if the sentinel variable does not change to make the comparison FALSE
- If an infinite loop condition occurs, you may have to reset your computer & will lose any changes that have not been saved
- If you get an infinite loop, wait, Windows may detect it & display a message box saying you have a slow running program & asking if you want to abort it - answer yes
- Loop Safety:
- You set it up during testing
- Create a variable Dim intSafety As Integer
- Before you start the loop, initialize intSafety = 0
- Inside the loop, decrement intSafety = intSafety + 1
- Inside the loop, test If intSafety > 10000 Then display an exit message & End Sub
- VB Picture Box object - can display (print) multiple lines:
picOutput.Print ("hello world") ' print string literal
strOutput = "My name is Mike" ' initialize a variable
picOutput.Print (strOutput) ' print a variable
- Online VB6 Text: Sams Teach Yourself Visual Basic 6 - Chapter 8 - Visual Basic Looping
- Loop Syntax:
- Syntax of the DO WHILE LOOP:
Do While comparisontest1
Block of one or more Visual Basic statements A
Change the sentinel variable
Loop
DO WHILE will execute statements A while comparisontest 1 is TRUE
If FALSE the first time, statements A will never be executed
- Syntax of the DO UNTIL LOOP:
Do Until comparisontest2
Block of one or more Visual Basic statements B
Change the sentinel variable
Loop
DO UNTIL will execute statements B until comparisontest 2 becomes TRUE
If TRUE the first time, statements B will never be executed
- Syntax of the DO LOOP WHILE:
Do
Block of one or more Visual Basic statements C
Change the sentinel variable
Loop While comparisontest3
Similar to the DO UNTIL execute statements C while comparison test 3 is TRUE
Will ALWAYS execute statements C at least once
- Syntax of the DO LOOP UNTIL:
Do
Block of one or more Visual Basic statements D
Change the sentinel variable
Loop Until comparisontest4
Similar to the DO UNTIL execute statements D until comparison test 4 becomes TRUE
Will ALWAYS execute statements D at least once
- Syntax of the FOR NEXT:
For counterVar = startVal To endVal [Step incrementVal]
Block of one or more Visual Basic statements E
The sentinel variable (counterVar) changes automatically
Next CounterVar
Will execute statements E (endVal - startVal) times
If startVal is greater than endVal, will not execute statements E at all
- Lab Assignment -
- On-screen practice with Picture Box object & print:
- Add a picture box object titled "picOutput", make it large
- Display "Hello World" to the picture box object inside a command button event
- Initialize a string variable & display the contents
- Use "picOutput.Cls" inside another command button event to clear screen the picture box
- Create a Visual Basic program "vbNumberLoops" to display number sequences:
- Display a series of numbers from 1 to 10
- Display odd numbers from 1 to 10
- Display multiples of three (3,6,9
|