Math Game - Help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using function like so:
Public Class Calculation
'add function
Public Function add(ByVal num1, ByVal num2)
Return (num1 + num2)
End Function
'subtract function
Public Function subtract(ByVal num1, ByVal num2)
Return (num1 - num2)
End Function
'divide function
Public Function Divide(ByVal num1, ByVal num2)
Return (num1 / num2)
End Function
'Multiply function
Public Function multiply(ByVal num1, ByVal num2)
Return (num1 * num2)
End Function
End Class
How do I display the problem to a label and get the correct answer, by the
way the user has a txtbox for her answer
 
In each Member Function compose the appropriate string. For example in the
Add Function.

labelName.text = num1.ToString() & " + " & num2.ToString()

Regards - OHM




--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
 
Private Sub newQuestionButton_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles newQuestionButton.Click
Dim r As New Random
txtOp1.Text = r.Next(1, 15)
txtOp2.Text = r.Next(1, 15)
lblAns.Text = ""
txtAns.Clear()


End Sub

Private Sub submitButton_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles submitButton.Click


'Get Answer
Dim answer As Integer

If Me.radAdd.Checked Then

answer = Convert.ToInt32(txtOp1.Text) +
Convert.ToInt32(txtOp2.Text)
Else
answer = Convert.ToInt32(txtOp1.Text) -
Convert.ToInt32(txtOp2.Text)
End If

Try

If answer = Convert.ToInt32(txtAns.Text) Then
lblAns.Text = "Correct"
Else
lblAns.Text = "Wrong, amnswer was " & answer.ToString
End If



Catch ex As ArgumentOutOfRangeException
lblAns.Text = ex.Message
Catch ex As Exception
lblAns.Text = ex.Message
End Try

End Sub

--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top