|
-
May 28th, 2002, 07:09 PM
#1
Thread Starter
New Member
help with a vb maths program
Im a total newbie when it comes to vb stuff
i got a little mathsprogram im trying to get done, i have 3 option buttons and then a start button, what i want to do is when i have a certain option clicked (easy, medium and hard) and when i click start, i want some random numbers come up (for easy it will be 1 digit numbers, medium will have 2 digits, and hard 3 digits)
my whole code is
[vb]
Public dang1 As Integer
Public dang2 As Integer
Public dang3 As Integer
Dim value As Integer
Private Sub check_Click()
Let dang1 = num1.Text
Let dang2 = num2.Text
Let dang3 = num3.Text
If dang1 + dang2 = dang3 Then
Call MsgBox("That answer is correct!", vbOKOnly, "Correct")
Else
Call MsgBox("That answer is wrong, Try again!", vbOKOnly, "Incorrect")
End If
End Sub
Private Sub easy_Click()
Randomize Timer 'The text box fields where the answer and questions appear.
Let num1.Text = Int(Rnd * 10)
Let num2.Text = Int(Rnd * 10)
Let dang1 = num1.Text
Let dang2 = num2.Text
End Sub
Private Sub exit_Click()
End
End Sub
Private Sub hard_Click()
Randomize Timer 'The text box fields where the answer and questions appear.
Let num1.Text = Int(Rnd * 1000)
Let num2.Text = Int(Rnd * 1000)
Let dang1 = num1.Text
Let dang2 = num2.Text
End Sub
Private Sub medium_Click()
Randomize Timer 'The text box fields where the answer and questions appear.
Let num1.Text = Int(Rnd * 100)
Let num2.Text = Int(Rnd * 100)
Let dang1 = num1.Text
Let dang2 = num2.Text
End Sub
Private Sub start_Click()
Randomize Timer 'The text box fields where the answer and questions appear.
Let num1.Text = Int(Rnd * 10)
Let num2.Text = Int(Rnd * 10)
Let dang1 = num1.Text
Let dang2 = num2.Text
End Sub[/vb]
[insert funny comment here]
-
May 28th, 2002, 07:19 PM
#2
Could I just make a suggestion before u get to far.
One methid could be to assign an offSet to one block of code only.
What I mean is don't use 3 blocks, Hard, Med, Easy. Just use
one, and use the "Selection" to dictate the offSet Value.
Like:
VB Code:
Select Case True
Case OptHard
offSet = 1000
Case OtpMed
offSet = 100
Case OptEasy
offSet = 10
End Select
And just use the bolck code once with the offSet:
VB Code:
Randomize Timer 'The text box fields where the answer and questions appear.
Randomize
Let num1.Text = Int(Rnd * offSet)
Let num2.Text = Int(Rnd * offSet)
Let dang1 = num1.Text
Let dang2 = num2.Text
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
|