d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > New Project In > Visual Basic
Add Reply New Topic New Poll
Member
Posts: 12,155
Joined: Mar 25 2006
Gold: 2,154.00
Dec 1 2013 10:16pm
My professor gave us this assignment.

"Write a visual basic program that has two labels, two text fields, and a button. The first text field should be labeled "first name"
the second text field should be labeled "last name". The two text fields start out blank.
The button should be labeled "check". If the user enters the programmer's (that's you )first name in the first text and enters the programmers last name in the second text field the button should change it's label to correct.
If it is incorrect the button should tell the user what the programmer's name is and change to "correct finally" if the user corrects it and clicks.

What I'm confused on is basically how would you write that first and last name is correct in the code?

If txtfirst.Text = "first name" Then stuck here..

Would I put Then btncheck.Text = Correct?
idk, and what if it's wrong how do I tell the code it's wrong/
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Dec 1 2013 10:26pm
Quote (JoeKer @ Dec 1 2013 11:16pm)
My professor gave us this assignment.

"Write a visual basic program that has two labels, two text fields, and a button.  The first text field should be labeled "first name"
the second text field should be labeled "last name".  The two text fields start out blank. 
The button should be labeled "check".  If the user enters the programmer's (that's you )first name in the first text and enters the programmers last name in the second text field the button should change it's label to correct. 
If it is incorrect the button should tell the user what the programmer's name is and change to "correct finally" if the user corrects it and clicks.

What I'm confused on is basically how would you write that first and last name is correct in the code?

If txtfirst.Text = "first name" Then  stuck here..

Would I put Then btncheck.Text = Correct?

idk, and what if it's wrong how do I tell the code it's wrong/


thats the general idea, yes.
Member
Posts: 12,155
Joined: Mar 25 2006
Gold: 2,154.00
Dec 1 2013 10:37pm
Quote (carteblanche @ Dec 1 2013 09:26pm)
thats the general idea, yes.


How do I get the button to change?

How do I tell the button to says "correct" when entered?

Edit, and if they enter it wrong, how do I command it to fix it? LOL this is so stupid.



This post was edited by JoeKer on Dec 1 2013 10:49pm
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Dec 1 2013 11:06pm
Quote (JoeKer @ Dec 1 2013 11:37pm)
How do I get the button to change?

How do I tell the button to says "correct" when entered?

Edit, and if they enter it wrong, how do I command it to fix it? LOL this is so stupid.


this doesn't work?

btncheck.Text = "Correct"
Member
Posts: 12,155
Joined: Mar 25 2006
Gold: 2,154.00
Dec 1 2013 11:11pm
Public Class frmForm1

Private Sub btncheck_Click(sender As Object, e As EventArgs) Handles btncheck.Click
If txtfirst.Text = "J" And
txtsecond.Text = "Y" Then
btncheck.Text = "Correct"
Else : btncheck.Text = "Correct Finally"
If btncheck.Text = "Correct" Then
txtfirst.Text = "J" And
txtsecond.Text = "Y"
End If
End If

End Sub

If I put my name is correctly from the start it says "Correct" This is good,
If I put it in wrong it says "Correct Finally" This is suppose to change the textfields to the right name and then say correct finally.
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Dec 1 2013 11:15pm
Quote (JoeKer @ Dec 2 2013 12:11am)
Public Class frmForm1

    Private Sub btncheck_Click(sender As Object, e As EventArgs) Handles btncheck.Click
        If txtfirst.Text = "J" And
              txtsecond.Text = "Y" Then
            btncheck.Text = "Correct"
        Else : btncheck.Text = "Correct Finally"
            If btncheck.Text = "Correct" Then
                txtfirst.Text = "J" And
                    txtsecond.Text = "Y"
            End If
        End If

    End Sub

If I put my name is correctly from the start it says "Correct"  This is good,
If I put it in wrong it says "Correct Finally"  This is suppose to change the textfields to the right name and then say correct finally.


get rid of "And" where bolded. then play with it.
Member
Posts: 12,155
Joined: Mar 25 2006
Gold: 2,154.00
Dec 1 2013 11:23pm
Didn't change nothing.
Where I am confused is from my professors instructions
If it is incorrect the button should tell the user what the programmer's name is and change to "correct finally" if the user corrects it and clicks.

Where should it correct my name ? In the textfields right? So if they get my name wrong click check, it should change the textfields to the correct name and then click again it it'll say "correct finally"?
Member
Posts: 12,155
Joined: Mar 25 2006
Gold: 2,154.00
Dec 2 2013 12:48am
nvm figured it out thanks for all the help , really appreciate it!
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll