473,320 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Math Game - Help

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
Nov 21 '05 #1
2 1195
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))
--
"freddy" <fr****@discussions.microsoft.com> wrote in message
news:57**********************************@microsof t.com...
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

Nov 21 '05 #2

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))
--
"freddy" <fr****@discussions.microsoft.com> wrote in message
news:57**********************************@microsof t.com...
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

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Charlie Cosse | last post by:
Tux Math Scrabble is written in python and uses PyGame for multimedia. Tux Math Scrabble is a math version of the popular board game for ages 4-40, which is highly entertaining as well as great...
23
by: Thomas Mlynarczyk | last post by:
I remember there is a programming language where you can initialize the random number generator, so that it can - if you want - give you the exactly same sequence of random numbers every time you...
5
by: Ark | last post by:
Hi everyone, Does anyone know if Direct3D overloads System.Math functions? Also is it possible to access the base functions of the overloaded function (in other words restore original of the...
17
by: kiplring | last post by:
float sum = (float)Math.Sqrt( floatA*floatA + floatB*floatB); I'm using DirectX with c#. But the Math class in .net framework has a problem. It is "double" base! So I'm doing type casting...
6
by: Mitchell Vincent | last post by:
Just making sure I'm not missing the boat here, but are there any special routines for doing currency math (fixed precision stuff) in .NET? The wonderful problems of doing math on decimals tend...
5
by: Martin Vilcans | last post by:
Hi, I'm new to this mailing list and fairly new to Python as well. I'm working on a prototype for a 3D game using OpenGL, and take this opportunity to learn Python better. I'm looking for a good...
7
by: Gasten | last post by:
Hello. The last weeks I've been coding a roguelike (you know, like nethack) in python using the nCurses library. Some week ago I ran into a problem: When I made the object for messagebar-output, I...
1
hpbutterbeer
by: hpbutterbeer | last post by:
We have a Machine Project and my brain is currently in a clouded state. Sorry, I'm just a beginner in C Programming... Text twist is a windows game whose main objective is to form words out of the...
2
by: TurtleGuy910 | last post by:
I made a math game and wanted it to print out which questions you got right at the end. How do i do that? This is my code. # Welcome To The Math Game print "Welcome To The Math Game." print...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.