|
-
Jul 15th, 2006, 09:56 AM
#1
Thread Starter
Junior Member
-
Jul 15th, 2006, 10:08 AM
#2
Re: [02/03] Programme just wont work!!
 Originally Posted by Vonni
Hi I am new at this and I have designed and written a programme for a Flash Card Addition Problem.
Everything seems to work except for one thing  , please if there is anyone out there who can help I would be very very grateful.
 This is where I am having a problem, when I type in the answer and press the answer button, if it is right it is supposed to give you the right answer and turn green and say well done, but if it is the wrong answer it is supposed to turn red and say sorry try again, but only one half of this is working - please somebody point out where I have gone wrong with this.
Thanks
Vonni
xxx
Private Sub btnAnswer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAnswer.Click
txtAnswer.Text = "" & Val(Val(lblView1.Text) + Val(lblView3.Text))
If txtTypeAnswer Is Label1 = False Then
lblCorrectWrong.BackColor = Color.Green
lblCorrectWrong.Text = "Well Done!"
ElseIf Label1 Is txtTypeAnswer = True Then
lblCorrectWrong.BackColor = Color.IndianRed
lblCorrectWrong.Text = "SorryTry Again"
End If
Hi,
You could try something like this:
VB Code:
Private Sub btnAnswer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAnswer.Click
If txtAnswer.Text = Val(Val(lblView1.Text) + Val(lblView3.Text)) then
MsgBox(" Well Done")
txtAnswer.BackColor = Color.Green
else
MsgBox("Try Again")
txtAnswer.BackColor = Color.Red
End If
I didn't tested, but you can try it.
Wkr,
sparrow1
-
Jul 15th, 2006, 10:20 AM
#3
Thread Starter
Junior Member
Re: [02/03] Programme just wont work!!
Thanks very, very, much, You are a Genius!!
You Rock!!

If you don't have anything nice to say, don't say anything at all. 
-
Jul 15th, 2006, 10:29 AM
#4
Re: [RESOLVED] [02/03] Programme just wont work!!
Please avoid Val(), it is an offense in some nations.
VB Code:
Private Sub btnAnswer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAnswer.Click
If txtAnswer.Text = (Convert.ToInt32(lblView1.Text) + Convert.ToInt32(lblView3.Text)).ToString() then
MsgBox(" Well Done")
txtAnswer.BackColor = Color.Green
else
MsgBox("Try Again")
txtAnswer.BackColor = Color.Red
End If
-
Jul 15th, 2006, 10:34 AM
#5
Re: [02/03] Programme just wont work!!
 Originally Posted by Vonni
Thanks very, very, much, You are a Genius!!
You Rock!!
Hi,
No problem glad to help!
Wkr,
sparrow1
-
Jul 15th, 2006, 04:31 PM
#6
Thread Starter
Junior Member
Re: [RESOLVED] [02/03] Programme just wont work!!

If you don't have anything nice to say, don't say anything at all. 
-
Jul 24th, 2006, 08:39 AM
#7
Re: [RESOLVED] [02/03] Programme just wont work!!
 Originally Posted by mendhak
Please avoid Val(), it is an offense in some nations.
VB Code:
Private Sub btnAnswer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAnswer.Click
If txtAnswer.Text = (Convert.ToInt32(lblView1.Text) + Convert.ToInt32(lblView3.Text)).ToString() then
MsgBox(" Well Done")
txtAnswer.BackColor = Color.Green
else
MsgBox("Try Again")
txtAnswer.BackColor = Color.Red
End If
Hi mendhak,
Sorry for this late reply!
Can you explain me a little more why we have to avoid the Val() function?
We need the Val() function to returns the numeric value, because the value stored in the Text property is not a number. It's a string such as "535", which is diffrent from the numeric value 535.
That's why we use the Val() function.
Does Convert.ToInt32 teh same thing like the Val() function?
I want always learn more!
Thanks in advance,
sparrow1
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|