Results 1 to 4 of 4

Thread: Need help with multiplication program

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2005
    Posts
    1

    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.

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    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


    Has someone helped you? Then you can Rate their helpful post.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Need help with multiplication program

    Are you intending this to be a Console app or are you wanting to create a GUI?

  4. #4
    Lively Member
    Join Date
    May 2005
    Posts
    90

    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.

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