Jeff Bolton
12-06-01, 12:02 PM
i'm so proud of myself!!! teacher said if we didn't start it before this weekend we wouldn't finish....i proved him wrong :D the link to the assignment is here: http://www.radford.edu/~kstevens2/cpsc109/assign/VBprogram2.htm . this is the final programming assignment for the semester.
here's my code in Visual Basic 6.0 already documented:
'Program Name: Assignment 2
'Programmer: Jeff Bolton
'Usage: none
'Compile: part4.vbs and part4.frm
'System: Microsoft Visual Basic 6.0 Working Model running on an AMD System with Windows 2000 Professional.
'Date: Started Saturday December 1st 2001, Completed Thursday December 5th 2001
'Bugs: No known bugs
'Description: Program is designed to give users a choice between 4 grade levels of multiplication problems. If they get more than 75% of attempts wrong after answering 10 right, the program ends and tells the user to get extra help.
Dim rightcounter As Integer
Dim wrongcounter As Integer
Dim multiplier As Integer
Dim gradelevel As Integer
'Funtion: cmdExit
'Purpose: Exits the Program
'Parameters: None
'Called By: none
'Side Effects: None
Private Sub cmdExit_Click()
End
End Sub
'Function: cmdGenerate
'Purpose: Generates the math problem
'Parameters: a, b, c
'Called by: none
'Side Effects: None
Private Sub cmdGenerate_Click()
Call GenerateNumbers(a, b, c)
End Sub
'Function: GenerateNumbers
'Purpose: Does all of the math for the cmdGenerate function
'Parameters: num1, num2, num3
'Called by: cmdGenerate
'Side Effects: none
Public Function GenerateNumbers(num1, num2, num3)
num1 = Int(Rnd * multiplier)
num2 = Int(Rnd * multiplier)
num3 = num1 * num2
str1 = "What is " & num1 & " times " & num2 & "?"
resp = Val(InputBox(str1))
Do While resp <> num1 * num2
wrongcounter = wrongcounter + 1
wrongcomment = Int(Rnd * 4) + 1
Select Case wrongcomment
Case 1
picOutput.Print "No, Please Try Again"
Case 2
picOutput.Print "Wrong, Try Once More"
Case 3
picOutput.Print "Don't Give Up!"
Case 4
picOutput.Print "No, Keep Trying"
End Select
resp = Val(InputBox(str1))
Loop
rightcomment = Int(Rnd * 4) + 1
If resp = num1 * num2 Then
rightcounter = rightcounter + 1
End If
Select Case rightcomment
Case 1
picOutput.Print "Very Good!"
Case 2
picOutput.Print "Excellent!"
Case 3
picOutput.Print "Nice Work!"
Case 4
picOutput.Print "Keep Up The Good Work!"
End Select
If rightcounter = 10 Then
picOutput.Print "You Have Answered 10 problems correctly and you have had"
picOutput.Print "to guess"; wrongcounter; "problems more than once."
If wrongcounter = 0 Then
picOutput.Print "Percentage of Correct Responses: 100%"
picOutput.Print "Continue Doing Your Math! You're Doing Great!"
End If
If wrongcounter <> 0 Then
picOutput.Print "Percentage of Correct Responses: "; ((wrongcounter / rightcounter) * 100); "%"
If ((wrongcounter / rightcounter) * 100) > 75 Then
MsgBox "Please See Your Instructor For Extra Help"
End
Else
picOutput.Print "Continue Doing Your Math! You're Doing Great!"
End If
End If
End If
End Function
'Function: Form_Load
'Purpose: Loads an InputBox for the user to choose which grade level of multiplaction to use, then tells GenerateNumbers what numbers to use for the multiplication.
'Parameters: none
'Called by: main
'Side Effects: none
Private Sub Form_Load()
gradelevel = Val(InputBox("Please Choose A Grade Level For Your Multiplication Problems (1-4)"))
Select Case gradelevel
Case 1
multiplier = 10
Case 2
multiplier = 100
Case 3
multiplier = 1000
Case 4
multiplier = 10000
Case Else
Do While gradelevel > 4
gradelevel = Val(InputBox("Please Choose A Grade Level For Your Multiplication Problems (1-4)"))
Loop
Do While gradelevel = 0
gradelevel = Val(InputBox("Please Choose A Grade Level For Your Multiplication Problems (1-4)"))
Loop
End Select
End Sub
just thought i'd put this in here, not that anyone cares, i'm just proud of myself. :D:D:D
jeff
here's my code in Visual Basic 6.0 already documented:
'Program Name: Assignment 2
'Programmer: Jeff Bolton
'Usage: none
'Compile: part4.vbs and part4.frm
'System: Microsoft Visual Basic 6.0 Working Model running on an AMD System with Windows 2000 Professional.
'Date: Started Saturday December 1st 2001, Completed Thursday December 5th 2001
'Bugs: No known bugs
'Description: Program is designed to give users a choice between 4 grade levels of multiplication problems. If they get more than 75% of attempts wrong after answering 10 right, the program ends and tells the user to get extra help.
Dim rightcounter As Integer
Dim wrongcounter As Integer
Dim multiplier As Integer
Dim gradelevel As Integer
'Funtion: cmdExit
'Purpose: Exits the Program
'Parameters: None
'Called By: none
'Side Effects: None
Private Sub cmdExit_Click()
End
End Sub
'Function: cmdGenerate
'Purpose: Generates the math problem
'Parameters: a, b, c
'Called by: none
'Side Effects: None
Private Sub cmdGenerate_Click()
Call GenerateNumbers(a, b, c)
End Sub
'Function: GenerateNumbers
'Purpose: Does all of the math for the cmdGenerate function
'Parameters: num1, num2, num3
'Called by: cmdGenerate
'Side Effects: none
Public Function GenerateNumbers(num1, num2, num3)
num1 = Int(Rnd * multiplier)
num2 = Int(Rnd * multiplier)
num3 = num1 * num2
str1 = "What is " & num1 & " times " & num2 & "?"
resp = Val(InputBox(str1))
Do While resp <> num1 * num2
wrongcounter = wrongcounter + 1
wrongcomment = Int(Rnd * 4) + 1
Select Case wrongcomment
Case 1
picOutput.Print "No, Please Try Again"
Case 2
picOutput.Print "Wrong, Try Once More"
Case 3
picOutput.Print "Don't Give Up!"
Case 4
picOutput.Print "No, Keep Trying"
End Select
resp = Val(InputBox(str1))
Loop
rightcomment = Int(Rnd * 4) + 1
If resp = num1 * num2 Then
rightcounter = rightcounter + 1
End If
Select Case rightcomment
Case 1
picOutput.Print "Very Good!"
Case 2
picOutput.Print "Excellent!"
Case 3
picOutput.Print "Nice Work!"
Case 4
picOutput.Print "Keep Up The Good Work!"
End Select
If rightcounter = 10 Then
picOutput.Print "You Have Answered 10 problems correctly and you have had"
picOutput.Print "to guess"; wrongcounter; "problems more than once."
If wrongcounter = 0 Then
picOutput.Print "Percentage of Correct Responses: 100%"
picOutput.Print "Continue Doing Your Math! You're Doing Great!"
End If
If wrongcounter <> 0 Then
picOutput.Print "Percentage of Correct Responses: "; ((wrongcounter / rightcounter) * 100); "%"
If ((wrongcounter / rightcounter) * 100) > 75 Then
MsgBox "Please See Your Instructor For Extra Help"
End
Else
picOutput.Print "Continue Doing Your Math! You're Doing Great!"
End If
End If
End If
End Function
'Function: Form_Load
'Purpose: Loads an InputBox for the user to choose which grade level of multiplaction to use, then tells GenerateNumbers what numbers to use for the multiplication.
'Parameters: none
'Called by: main
'Side Effects: none
Private Sub Form_Load()
gradelevel = Val(InputBox("Please Choose A Grade Level For Your Multiplication Problems (1-4)"))
Select Case gradelevel
Case 1
multiplier = 10
Case 2
multiplier = 100
Case 3
multiplier = 1000
Case 4
multiplier = 10000
Case Else
Do While gradelevel > 4
gradelevel = Val(InputBox("Please Choose A Grade Level For Your Multiplication Problems (1-4)"))
Loop
Do While gradelevel = 0
gradelevel = Val(InputBox("Please Choose A Grade Level For Your Multiplication Problems (1-4)"))
Loop
End Select
End Sub
just thought i'd put this in here, not that anyone cares, i'm just proud of myself. :D:D:D
jeff