-
Jun 16th, 2005, 02:10 PM
#1
Thread Starter
New Member
Need help with multiplication program
I'm trying to write a program that asks a multiplication question, which need to be a Sub procedure, and I'm having difficulty with starting out. I'm obviously new to this and I'm trying to learn how to do this. Any help would be greatly appreciated.
-
Jun 16th, 2005, 04:36 PM
#2
-
Jun 16th, 2005, 07:37 PM
#3
Re: Need help with multiplication program
Are you intending this to be a Console app or are you wanting to create a GUI?
-
Jun 16th, 2005, 08:11 PM
#4
Lively Member
Re: Need help with multiplication program
I'll write up something here, excuse me if I typo anything!
Code:
sub AskQuestion()
Dim FinalAnswer as integer
Dim GivenAnswer as integer
Dim Num1, Num2 as integer
Randomize()
Num1 = int(rnd * 10) + 1 'Makes number 1-9
Num2 = int(rnd * 10) + 1 'Makes number 1-9
FinalAnswer = Num1 * Num2
''' Ok, time to ask question.
GivenAnswer = InputBox("What is " & Num1 & " times " & Num2 & "?" , "My Multiplication Question!")
If GivenAnswer = FinalAnswer then
MsgBox("Great Job!")
else
MsgBox("Sorry - the answer was " & FinalAnswer)
End Sub
Simply paste that sub into your app (within the form class of course), and invoke it from Form_Load sub by just putting the line AskQuestion(). You can also add a button, and double click it in the designer to have it make a new Sub that is triggered when you click it. Putting AskQuestion() in that sub will make it ask the question each time you click.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|