|
|
Download the CheckBox Sales Assignment.
The following equation will round your decimals to 2 places.
total = total * 1.0925 + total 'Adds tax
total = (Int(total * 100)) / 100 'rounds to 2 decimal places
Read page 109 about CheckBoxes
You can check as many check boxes as you want. The prefix for CheckBox is chk.
Dot checked returns true or false : chkPizza.Checked = true or false
If chkPizza.Checked = True Then
total = total + 7.99
End If
The code for a check box can be under the check box or under a button. It depends on the program. More examples to come.
Enter the Review program MorningToDo on pages 110 & 111. Code will be under a check box and the button.
Randomize
Dim rand As Integer
rand = Int(100* Rnd() +1) 'Generates a random number between 1 and 100
1. Modify the NumberGuess program.
Set the SECRET_NUMBER to a random number between 1 and 100.
Change the label on the form to say 100, instead of 10.
Add a global variable called count and set it to 0.
Add the equation count = count + 1 under the button
Change the message in lblMessage to say "You got it in " & count & " tries."
2. Create a Slot Machine program. Download the instructions above.
***************************************************************
Enter the code for the NumberGuess program on pages 94 & 95.
Write a program that has a text box, a label for the letter grade and a button. Use an If-Then-EndIf statement to determine if the grade is A, B, C, D or F and show the letter grade in the label box. (Look at the notes)
p. 121 Exercise 1 NumberOfDigits
p. 122 Exercise 3 Copies
Logical Operators
and – both conditions must be true – if grade >=93 and grade <=100 then
Me.lblGrade.Text = "You got an A!"
or – one condition must be true – if guess < 1 or guess > 10 then
Me.lblguess.Text = "Guess a number between 1 and 10."
The following equation will round your decimals to 2 places.
total = total * 1.0925 + total 'Adds tax
total = (Int(total * 100)) / 100 'rounds to 2 decimal places
Read page 109 about CheckBoxes
You can check as many check boxes as you want. The prefix for CheckBox is chk.
Dot checked returns true or false : chkPizza.Checked = true or false
If chkPizza.Checked = True Then
total = total + 7.99
End If
The code for a check box can be under the check box or under a button. It depends on the program. More examples to come.
Enter the Review program MorningToDo on pages 110 & 111. Code will be under a check box and the button.
Randomize
Dim rand As Integer
rand = Int(100* Rnd() +1) 'Generates a random number between 1 and 100
1. Modify the NumberGuess program.
Set the SECRET_NUMBER to a random number between 1 and 100.
Change the label on the form to say 100, instead of 10.
Add a global variable called count and set it to 0.
Add the equation count = count + 1 under the button
Change the message in lblMessage to say "You got it in " & count & " tries."
2. Create a Slot Machine program. Download the instructions above.
***************************************************************
Enter the code for the NumberGuess program on pages 94 & 95.
Write a program that has a text box, a label for the letter grade and a button. Use an If-Then-EndIf statement to determine if the grade is A, B, C, D or F and show the letter grade in the label box. (Look at the notes)
p. 121 Exercise 1 NumberOfDigits
p. 122 Exercise 3 Copies
Logical Operators
and – both conditions must be true – if grade >=93 and grade <=100 then
Me.lblGrade.Text = "You got an A!"
or – one condition must be true – if guess < 1 or guess > 10 then
Me.lblguess.Text = "Guess a number between 1 and 10."