Results 1 to 7 of 7

Thread: [RESOLVED] [02/03] Programme just wont work!!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2006
    Posts
    19

    Resolved [RESOLVED] [02/03] Programme just wont work!!

    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

    If you don't have anything nice to say, don't say anything at all.

  2. #2
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: [02/03] Programme just wont work!!

    Quote 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:
    1. Private Sub btnAnswer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAnswer.Click
    2.         If txtAnswer.Text = Val(Val(lblView1.Text) + Val(lblView3.Text)) then
    3. MsgBox(" Well Done")
    4. txtAnswer.BackColor = Color.Green
    5. else
    6. MsgBox("Try Again")
    7. txtAnswer.BackColor = Color.Red
    8.         End If

    I didn't tested, but you can try it.

    Wkr,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  3. #3

    Thread Starter
    Junior Member
    Join Date
    May 2006
    Posts
    19

    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.

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [RESOLVED] [02/03] Programme just wont work!!

    Please avoid Val(), it is an offense in some nations.

    VB Code:
    1. Private Sub btnAnswer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAnswer.Click
    2.         If txtAnswer.Text = (Convert.ToInt32(lblView1.Text) + Convert.ToInt32(lblView3.Text)).ToString() then
    3. MsgBox(" Well Done")
    4. txtAnswer.BackColor = Color.Green
    5. else
    6. MsgBox("Try Again")
    7. txtAnswer.BackColor = Color.Red
    8.         End If

  5. #5
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: [02/03] Programme just wont work!!

    Quote Originally Posted by Vonni
    Thanks very, very, much, You are a Genius!!
    You Rock!!
    Hi,

    No problem glad to help!

    Wkr,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  6. #6

    Thread Starter
    Junior Member
    Join Date
    May 2006
    Posts
    19

    Re: [RESOLVED] [02/03] Programme just wont work!!

    ????

    If you don't have anything nice to say, don't say anything at all.

  7. #7
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: [RESOLVED] [02/03] Programme just wont work!!

    Quote Originally Posted by mendhak
    Please avoid Val(), it is an offense in some nations.

    VB Code:
    1. Private Sub btnAnswer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAnswer.Click
    2.         If txtAnswer.Text = (Convert.ToInt32(lblView1.Text) + Convert.ToInt32(lblView3.Text)).ToString() then
    3. MsgBox(" Well Done")
    4. txtAnswer.BackColor = Color.Green
    5. else
    6. MsgBox("Try Again")
    7. txtAnswer.BackColor = Color.Red
    8.         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
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

Posting Permissions

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



Click Here to Expand Forum to Full Width