PDA

View Full Version : my first hard program


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

XprincoX
12-06-01, 09:55 PM
hehe.. gj!! but this is "the first of many!!" :D

ThePunkGeek
12-08-01, 10:40 PM
nice start

The Coolest
12-12-01, 03:08 PM
cool first app! continue the good work! LOL that just sounded like a phrase from ur proggie! :D

Vovan
12-19-01, 03:25 AM
Yeah, cool!
But think about optimization. on a 486 machine under win 95 this code will be running 20-30 min.

trapper
12-20-01, 04:41 AM
seems like you get a fine bit of computing taught to you over there and nice work man your age makes me feel like a right thicko, but i think a bit of constructive criticism would be good(do not mistake me for a programmer!lol) see your app is kewl but as your project mentioned the increasing role of the pc in education
personally think ythe man above has hit nail on head as the target group of users in this part of world would be like primary school kids who most likely if have a machine will be a older (486)type and because of this and the time the app would take to run.........mmmmmmmmmmm

hey but i aint you - you aint worried about nowt but passing your test - and your app will never live - but i guess you probably write some thing that lots of ppl will use soon - GOOD LUCK

aupilotxp
12-22-01, 05:27 PM
...nice job...as you know..I am just starting VB.....help me out when needed...see ya at the hut....

Marc

vlovich
01-01-02, 09:21 PM
No offence or anything, but that program seems a bit simple for a university student. I have an assignment to create a game. So far have made the first level, some options (located a memory leak and no the cuase; created temp solution). I have one problem which is flickering. Because of the creation of movement, the objects flicker. If anyone knows any methods (BitBlt, double buffering) and can wright down the exact code pertaining to the problem at hand, please right it down. I used gif's to use the transperancy option (if you notice, in VB a picture has no wrapping, just a square). Was too lazy to learn how to use modules, and a large chunk was finished before realized that modules were more efficient. Have been working on it on and off for approx. 2 weeks (max 1 hour at school, 2 hours at home). Redid the prog 1 or 2 times because of bugs.

PS. You can enable starry background. It slows it down as there are a lot of timers. Just remove the quotes in the coding for tmrStar.

PPS. Primary school students will doubtfully have a 486. Even a 233 with 32mb ram and win98se will be able to run it smoothly (there's barely any code) especially when you compile it.

The only difference between Genius and Stupidity is the Genius has it limits. - Albert Einstein

XWRed1
01-01-02, 09:42 PM
Is this the first assignment in your first university programming course too? Seems to assume you already know alot of stuff.

vlovich
01-02-02, 09:36 AM
Actually, I'm still in high school and we started from the basics two months ago. But the Real question is CAN ANYONE HELP ME (see above for details).

Valkyr
01-04-02, 04:43 PM
Have you tried using the move method as this should give a smoother movement than just changing the top and left values directly.

e.g

Image1.Move Image1.Left + 100, Image1.Top + 100

rather than

Image1.Left = Image1.Left + 100
Image1.Top = Image1.Top + 100

You might also want to experiment with the timer settings and distanced moved (slowing it down slightly may help).

Hope this helps.

Jeff Bolton
01-07-02, 07:33 AM
Originally posted by vlovich
No offence or anything, but that program seems a bit simple for a university student. I have an assignment to create a game. So far have made the first level, some options (located a memory leak and no the cuase; created temp solution). I have one problem which is flickering. Because of the creation of movement, the objects flicker. If anyone knows any methods (BitBlt, double buffering) and can wright down the exact code pertaining to the problem at hand, please right it down. I used gif's to use the transperancy option (if you notice, in VB a picture has no wrapping, just a square). Was too lazy to learn how to use modules, and a large chunk was finished before realized that modules were more efficient. Have been working on it on and off for approx. 2 weeks (max 1 hour at school, 2 hours at home). Redid the prog 1 or 2 times because of bugs.

PS. You can enable starry background. It slows it down as there are a lot of timers. Just remove the quotes in the coding for tmrStar.

PPS. Primary school students will doubtfully have a 486. Even a 233 with 32mb ram and win98se will be able to run it smoothly (there's barely any code) especially when you compile it.

The only difference between Genius and Stupidity is the Genius has it limits. - Albert Einstein

this was an introduction to programming class, assuming we had no programming experience (which i didn't). it wasn't a strictly visual basic class...if it was, i'm sure we'd be doing harder stuff. as far as we got in the book was "for" statements. but i see what you are meaning...this isn't the first thing that i had to do in the class but it was pretty much a culmination of most of what we had done.

jeff