Can somebody help me with my scoring system?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2

Thread: Can somebody help me with my scoring system?

  1. #1
    Join Date
    Jan 2015

    Can somebody help me with my scoring system?

    Hi i'm trying to create a basic maths quiz which will firstly ask the student 3 questions and display how many he has scored out of 10, but i can't seem to get the score to work, this is what i have got so far:
    Public Class Form1
        'Randomiser function 
        Public Function rand(ByVal low As Long, _
    ByVal high As Long) As Long
            rand = Int((high - low + 1) * Rnd()) + low
        End Function
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            'Variables which will be declaring throughout the code
            Dim highnum As Integer
            Dim lownum As Integer
            Dim answer As Integer
            Dim score As Integer
            Dim addition As Integer
            score = 1
            addition = 1
            'This section will be the first section of the code, which will diplay 4 addition sums
            Do While addition < 4
                highnum = rand(1, 12)
                lownum = rand(1, 6)
                answer = highnum + lownum
                If InputBox("What is " & highnum & "+" & lownum) = answer Then
                    score = score + 1 & MsgBox("well done" & score)
                End If
                addition = addition + 1
            MsgBox("You have scored" & score & "out of 10")

  2. #2
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008

    Re: Can somebody help me with my scoring system?

    score = score + 1 & MsgBox("well done" & score)
    You need to get that part in red off that line.
    If you want to add to the score then that is one line
    display the score should be another line.

    Also note that you should not start more than one thread on the same question. I have deleted the thread you created in the VB6 section as this is VB.Net code.

    You shoudl also be more descriptive than just saying it doesn't work. Many will not even bother to try and help when you fail to provide the required info. In this case I would guess that you are getting a Type Mismatch error message on the line I have quoted.
    Last edited by DataMiser; January 13th, 2015 at 10:16 PM.
    Always use [code][/code] tags when posting code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)