Maths Tutor

tomsmith19
10-25-2004, 12:12 PM
hi, im tryin to create a basic maths tutor program, that will randomly pick a number between 1-12 and either add (+) or multiply (x) it.

iv got:

Dim num1 As Double
Dim num2 As Double


Private Sub plus()
num1 = Int(1 + 12 = Rnd())
num2 = Int(1 + 12 = Rnd())
opname = "plus"
End Sub

and:

Private Sub Form_Load()
Call plus
Label1.Caption = "What is " & num1 + opname & num2
End Sub

and i want it to randomly pick numbers and then u have to put the answer in a text box and click ok, then a message will pop up sayin if its right or wrong.

the problem im havin is wit the 'opname'. when i run the program this isnt recognised and if i declare it it causes problems!

any1 know how 2 sort this pls?

loquin
10-25-2004, 12:34 PM
Try This (Changes in dark red)Dim num1 As Double
Dim num2 As Double
DIM opname as String

Private Sub plus()
num1 = Int(1 + 12 = Rnd())
num2 = Int(1 + 12 = Rnd())
opname = "plus"
End Sub

and:

Private Sub Form_Load()
Call plus
Label1.Caption = "What is " & num1 & " " & opname & " " & num2
End Sub

tomsmith19
10-25-2004, 12:39 PM
thanx, that sorted it!!!

how can i get the numbers to randomize between 1-12? they keep stayin on 0 plus 0?!

Diurnal
10-25-2004, 12:47 PM
Int(Rnd * 12 +1)

tomsmith19
10-26-2004, 09:59 AM
iv got it 2 display plus now. how can i add a minus to the program and get it to randomise between them?

tomc2506
10-26-2004, 11:27 AM
Select Case Int(Rnd * 2) + 1
Case 1
opname = "plus"
Case 2
opname = "minus"
End Select

You may want to use Randomize once in Form_Load as well, but it's useful for debugging if you don't do that till right before compiling.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum