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.
Re: Need help with multiplication program
Welcome to VBF MLavoie :)
I moved your thread from the Codebank to the VB.Net section. The codebank is for posting code samples, not questions :)
Re: Need help with multiplication program
Are you intending this to be a Console app or are you wanting to create a GUI?
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.