|
|
Visual Basic
03 Decision Programs - Select Case
Use Select Case to allow the computer to make
decisions regarding inputted information. Pay attention to the
string/numeric data type being used. Of Particular note
are:
- a single option in a case statement
Case 3
Case "A"
- multiple options in a case statement
Case 1, 2, 3, 4
Case "a", "b", "c"
- inequality options in a case statement
Case is < 3
Case is >"A"
- a range of values in a case statement
Case "A" to "F"
Case 10 to 99
Every Select Case statement should have a Case
Else as the final case.
All programs should be in one form use a file menu format for selecting the appropriate problem. Name the file
03xxx_sc where xxx is your initials.. Use an if-then
statement with an exit sub to trap for the user pressing the Cancel Button or
leaving the input box blank. Output should be placed in a message box msgbox()
function.
1. Input a number into an inputbox and determine
if the number is positive, negative or zero.
2. Determine if a character entered into an
inputbox is an upper case, lower case, or numeric character or a non-alphanumeric character.
3. Welkerville Water System uses a billing system which gradually decreases the cost for additional volumes of water. The following is a current cost chart.
- $33.95 for the first 3,000 gallons
- plus $3.95 additional for each additional 1,000 gallons up to 10,000 gallons
- plus $2.95 additional for each additional 1,000 gallons from 10,000 to 15,000 gallons
- plus $1.95 additional for each 1,000 gallons beyond 15,000 gallons
Input the number of gallons used in 1,000's. Determine the amount charged for the volume of water. (Ex. Enter 12 for 12,000 gallons).
4. Input the coefficients a, b, and c of a
quadratic equation ax2 + bx + c = 0. Use the discriminant
to determine if the equation has two real solutions, two non-real
solutions, or one real solution.
Visual Basic Assignment
Page
|
|