Results 1 to 2 of 2

Thread: help with a vb maths program

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2002
    Posts
    1

    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]

  2. #2
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    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:
    1. Select Case True
    2.   Case OptHard
    3.       offSet = 1000
    4.   Case OtpMed
    5.      offSet = 100
    6.   Case OptEasy
    7.      offSet = 10
    8. End Select

    And just use the bolck code once with the offSet:
    VB Code:
    1. Randomize Timer 'The text box fields where the answer and questions appear.
    2.  
    3.  Randomize
    4.  
    5.  Let num1.Text = Int(Rnd * offSet)
    6.  Let num2.Text = Int(Rnd * offSet)
    7.  Let dang1 = num1.Text
    8.  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
  •  



Click Here to Expand Forum to Full Width