vbchapter_3_variables_and_constants.docx |
Put String and math in the same text with &.
Me.lblArea.Text="Answer = " & area
Read page 71 about Scope
Local Variables – variables declared inside an object module only work inside that module
Global Variables – variables declared outside an object module, at the top under public class Form1 are available to all object modules in the program. They hold their value throughout the program.
Order of the code is important!
1. Declare – Dim the variables with data types – either local or global
2. Assign Value – Assign the value in the Text Box to the variables
3. vEquation – Use the variables in equation(s)
4. Show the answer – Assign the answer or variable to a label
Assignments:
Page 89
1. Exercise 2 a & b. Call the variable for the temperature in the text box temp.
In part b, add a menu that says F to C, C to F and Exit.
Use the code celcius = 5/9 * (temp-32) to solve for celcius.
Use the code fahrenheit =9/5 *temp+32 to solve for fahrenheit.
Page 90
2. Exercise 4 - Write the PizzaCost program. Make sure to include everything in the equation.
PUT YOUR NAME IN ALL PROGRAMS!!!!!
Read pages 65-70 about declaring & using variables, data types and TextBoxes for user input.
Follow the instructions on pages 66-70, and enter the program for SquareArea parts 1 and 2. Make sure you name everything!
After you finish the SquareArea parts 1 & 2, start a new program on page 69 and write the RectangleArea program.
On page 71, write TotalDistance. You will Dim 4 variables, segment1, segment2, segment3 and distance. All the code will go under the button.
Me.lblArea.Text="Answer = " & area
Read page 71 about Scope
Local Variables – variables declared inside an object module only work inside that module
Global Variables – variables declared outside an object module, at the top under public class Form1 are available to all object modules in the program. They hold their value throughout the program.
Order of the code is important!
1. Declare – Dim the variables with data types – either local or global
2. Assign Value – Assign the value in the Text Box to the variables
3. vEquation – Use the variables in equation(s)
4. Show the answer – Assign the answer or variable to a label
Assignments:
Page 89
1. Exercise 2 a & b. Call the variable for the temperature in the text box temp.
In part b, add a menu that says F to C, C to F and Exit.
Use the code celcius = 5/9 * (temp-32) to solve for celcius.
Use the code fahrenheit =9/5 *temp+32 to solve for fahrenheit.
Page 90
2. Exercise 4 - Write the PizzaCost program. Make sure to include everything in the equation.
PUT YOUR NAME IN ALL PROGRAMS!!!!!
Read pages 65-70 about declaring & using variables, data types and TextBoxes for user input.
Follow the instructions on pages 66-70, and enter the program for SquareArea parts 1 and 2. Make sure you name everything!
After you finish the SquareArea parts 1 & 2, start a new program on page 69 and write the RectangleArea program.
On page 71, write TotalDistance. You will Dim 4 variables, segment1, segment2, segment3 and distance. All the code will go under the button.