I have teo buttons ont the display the problem and for the user to submit the
answer, but it is not comparing the user's answer
Private Sub btnNQuestion_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNQuestion.Click
num1 = rand.Next(1, 15)
num2 = rand.Next(1, 15)
Dim sr As StreamReader
Dim sw As StreamWriter
Dim ans As String
If rbtnAdd.Checked Then
lblQuestion.Text = num1.ToString() & "+" & num2.ToString()
ElseIf rbtnSubtract.Checked Then
lblQuestion.Text = num1.ToString() & "-" & num2.ToString()
End If
txtanswer.Clear()
End Sub
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSubmit.Click
Dim ans As Integer
ans = (num1 + num2)
ans = (num1 - num2)
If ans = txtanswer.Text Then
lblNofQ.Text = "correct"
Else
lblNofQ.Text = "Incorrect"
End If
End Sub
End Class 5 971
In your submit function, you seem to set asn twice?!?
ans = (num1 + num2)
ans = (num1 - num2)
And Here, you are trying to compare an integer with a string, try
ans.ToString() = txtanswer.Text Then
If ans = txtanswer.Text Then
lblNofQ.Text = "correct"
Else
lblNofQ.Text = "Incorrect"
End If
--
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:3B**********************************@microsof t.com... I have teo buttons ont the display the problem and for the user to submit the answer, but it is not comparing the user's answer Private Sub btnNQuestion_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNQuestion.Click num1 = rand.Next(1, 15) num2 = rand.Next(1, 15) Dim sr As StreamReader Dim sw As StreamWriter Dim ans As String
If rbtnAdd.Checked Then lblQuestion.Text = num1.ToString() & "+" & num2.ToString() ElseIf rbtnSubtract.Checked Then lblQuestion.Text = num1.ToString() & "-" & num2.ToString()
End If txtanswer.Clear() End Sub
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click Dim ans As Integer ans = (num1 + num2) ans = (num1 - num2)
If ans = txtanswer.Text Then lblNofQ.Text = "correct" Else lblNofQ.Text = "Incorrect" End If End Sub End Class
My problem is how will the program know if it add, subtract, divide, or
multiply
"One Handed Man ( OHM - Terry Burns )" wrote: In your submit function, you seem to set asn twice?!?
ans = (num1 + num2) ans = (num1 - num2)
And Here, you are trying to compare an integer with a string, try
ans.ToString() = txtanswer.Text Then If ans = txtanswer.Text Then lblNofQ.Text = "correct" Else lblNofQ.Text = "Incorrect" End If
-- 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:3B**********************************@microsof t.com...I have teo buttons ont the display the problem and for the user to submit the answer, but it is not comparing the user's answer Private Sub btnNQuestion_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNQuestion.Click num1 = rand.Next(1, 15) num2 = rand.Next(1, 15) Dim sr As StreamReader Dim sw As StreamWriter Dim ans As String
If rbtnAdd.Checked Then lblQuestion.Text = num1.ToString() & "+" & num2.ToString() ElseIf rbtnSubtract.Checked Then lblQuestion.Text = num1.ToString() & "-" & num2.ToString()
End If txtanswer.Clear() End Sub
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click Dim ans As Integer ans = (num1 + num2) ans = (num1 - num2)
If ans = txtanswer.Text Then lblNofQ.Text = "correct" Else lblNofQ.Text = "Incorrect" End If End Sub End Class
Just use a bit of the code you used above:
If rbtnAdd.Checked Then
ans = num1 + num2
Else
If rbtnSubtract.Checked Then
ans = num1 - num2
End if
End if
That should work
see ya
Jacob
freddy wrote: My problem is how will the program know if it add, subtract, divide, or multiply
"One Handed Man ( OHM - Terry Burns )" wrote:
In your submit function, you seem to set asn twice?!?
ans = (num1 + num2) ans = (num1 - num2)
And Here, you are trying to compare an integer with a string, try
ans.ToString() = txtanswer.Text Then If ans = txtanswer.Text Then lblNofQ.Text = "correct" Else lblNofQ.Text = "Incorrect" End If
-- 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:3B**********************************@microsof t.com...I have teo buttons ont the display the problem and for the user to submit the answer, but it is not comparing the user's answer Private Sub btnNQuestion_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNQuestion.Click num1 = rand.Next(1, 15) num2 = rand.Next(1, 15) Dim sr As StreamReader Dim sw As StreamWriter Dim ans As String
If rbtnAdd.Checked Then lblQuestion.Text = num1.ToString() & "+" & num2.ToString() ElseIf rbtnSubtract.Checked Then lblQuestion.Text = num1.ToString() & "-" & num2.ToString()
End If txtanswer.Clear() End Sub
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click Dim ans As Integer ans = (num1 + num2) ans = (num1 - num2)
If ans = txtanswer.Text Then lblNofQ.Text = "correct" Else lblNofQ.Text = "Incorrect" End If End Sub End Class
here is my complete code. I am suppose to 1.display a problem and compare the
2.users answer and save it to a text file, but I can not past 2
any help- please
"Jacob Thastrup" wrote: Just use a bit of the code you used above:
If rbtnAdd.Checked Then ans = num1 + num2 Else If rbtnSubtract.Checked Then ans = num1 - num2 End if End if
That should work
see ya
Jacob freddy wrote:
My problem is how will the program know if it add, subtract, divide, or multiply
"One Handed Man ( OHM - Terry Burns )" wrote:
In your submit function, you seem to set asn twice?!?
ans = (num1 + num2) ans = (num1 - num2)
And Here, you are trying to compare an integer with a string, try
ans.ToString() = txtanswer.Text Then If ans = txtanswer.Text Then lblNofQ.Text = "correct" Else lblNofQ.Text = "Incorrect" End If
-- 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:3B**********************************@microsof t.com... >I have teo buttons ont the display the problem and for the user to submit >the > answer, but it is not comparing the user's answer > Private Sub btnNQuestion_Click(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles btnNQuestion.Click > num1 = rand.Next(1, 15) > num2 = rand.Next(1, 15) > Dim sr As StreamReader > Dim sw As StreamWriter > Dim ans As String > > If rbtnAdd.Checked Then > lblQuestion.Text = num1.ToString() & "+" & num2.ToString() > ElseIf rbtnSubtract.Checked Then > lblQuestion.Text = num1.ToString() & "-" & num2.ToString() > > End If > txtanswer.Clear() > End Sub > > Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles btnSubmit.Click > Dim ans As Integer > ans = (num1 + num2) > ans = (num1 - num2) > > If ans = txtanswer.Text Then > lblNofQ.Text = "correct" > Else > lblNofQ.Text = "Incorrect" > End If > End Sub > End Class
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:F7**********************************@microsof t.com... here is my complete code. I am suppose to 1.display a problem and compare the 2.users answer and save it to a text file, but I can not past 2 any help- please
"Jacob Thastrup" wrote:
Just use a bit of the code you used above:
If rbtnAdd.Checked Then ans = num1 + num2 Else If rbtnSubtract.Checked Then ans = num1 - num2 End if End if
That should work
see ya
Jacob freddy wrote:
> My problem is how will the program know if it add, subtract, divide, or > multiply > > "One Handed Man ( OHM - Terry Burns )" wrote: > > > In your submit function, you seem to set asn twice?!? > > > > ans = (num1 + num2) > > ans = (num1 - num2) > > > > > > And Here, you are trying to compare an integer with a string, try > > > > ans.ToString() = txtanswer.Text Then > > > > > > > > If ans = txtanswer.Text Then > > lblNofQ.Text = "correct" > > Else > > lblNofQ.Text = "Incorrect" > > End If > > > > -- > > 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:3B**********************************@microsof t.com... > > >I have teo buttons ont the display the problem and for the user to > > >submit > > >the > > > answer, but it is not comparing the user's answer > > > Private Sub btnNQuestion_Click(ByVal sender As System.Object, > > > ByVal e As > > > System.EventArgs) Handles btnNQuestion.Click > > > num1 = rand.Next(1, 15) > > > num2 = rand.Next(1, 15) > > > Dim sr As StreamReader > > > Dim sw As StreamWriter > > > Dim ans As String > > > > > > If rbtnAdd.Checked Then > > > lblQuestion.Text = num1.ToString() & "+" & > > > num2.ToString() > > > ElseIf rbtnSubtract.Checked Then > > > lblQuestion.Text = num1.ToString() & "-" & > > > num2.ToString() > > > > > > End If > > > txtanswer.Clear() > > > End Sub > > > > > > Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal > > > e As > > > System.EventArgs) Handles btnSubmit.Click > > > Dim ans As Integer > > > ans = (num1 + num2) > > > ans = (num1 - num2) > > > > > > If ans = txtanswer.Text Then > > > lblNofQ.Text = "correct" > > > Else > > > lblNofQ.Text = "Incorrect" > > > End If > > > End Sub > > > End Class > > > > > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: fowle040 |
last post by:
I underlined and bold print my files.
I need to know how to make this code into a working game.
The object of the game is to have two players 1- belle and 2-beast.
I want them to lose and gain...
|
by: mixmaster |
last post by:
Hi All
very new to programing so please excuse me
how would you create a math game in JAVA
say 5 questions
Thanks
|
by: Johannes Baagoe |
last post by:
About Math.random(), ECMA 262 just says "Returns a number value with
positive sign, greater than or equal to 0 but less than 1, chosen randomly
or pseudo randomly with approximately uniform...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
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)...
|
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...
|
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
|
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...
| |