Okay, my school has put me in charge of making a program, for the maths department. So i went out and bought vb6 (as i have been wanting to for a while now). Ive got the GUI and everything, its just i want to know how to do "sums"
As in, there are three text boxes box, going:
TB1 + TB2 = TB3
Now, i need a code or something, which will create a random number in TB1 and TB2. And when the user enters the answer (in TB3), it will display a tick, and "correct" or a cross and "incorrect"
I would like to achieve the above for multiplication, addition, subtraction and division.
Create a text box on the form
Text1.Text=TB1 + TB2
Create a random number generator
Private Sub Command1_Click()
Dim TB1 As Integer: Dim TB2 As Integer
Randomize Timer
TB1 = Rnd(0 + 1) * 100
Text1.Text = TB1
TB2 = Rnd(0 + 1) * 100
Text2.Text = TB2
End Sub
Yeah, but would that be able to pop up in a box? And alert. Well i suppose i could show form2 when commandVerify is clicked, and have txtOutput in there, then when they hit "OK" it hides it again?
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read. Please Help Us To Save Ana
Okay this is getting confusing, with saving an what not. So ive added my updated project. I have tried many methods, but i still cannot fix my problem. When i click the check button, it says incorrect no matter what the answer is.
Also here is the code:
Form 1:
Code:
Private Sub Form_Load()
Dim TB1 As Integer: Dim TB2 As Integer
Text1.Caption = TB1 + TB2
Randomize Timer
TB1 = Rnd(0 + 1) * 100
Text1.Caption = TB1
TB2 = Rnd(0 + 1) * 100
Text2.Caption = TB2
End Sub
Private Sub Command1_Click()
Dim TB1 As Integer: Dim TB2 As Integer
Randomize Timer
TB1 = Rnd(0 + 1) * 100
Text1.Caption = TB1
TB2 = Rnd(0 + 1) * 100
Text2.Caption = TB2
End Sub
Private Sub Command2_Click()
Form2.Show
End Sub
Form 2:
Code:
Private Sub Form_Load()
Dim form1 As New form1
lblOutput.Caption = IIf(form1.Text1 + form1.Text2 = form1.Text2, "Correct", "Incorrect")
End Sub
Private Sub Command1_Click()
Form2.Hide
End Sub
Last edited by adamlonsdale; Mar 10th, 2007 at 06:38 AM.