Results 1 to 3 of 3

Thread: Help fixing this error?

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2014
    Posts
    1

    Help fixing this error?

    I'm just beginning to learn how to program and am going through a tutorial right now. I have had no problems up until this point. It is having me assign textbox text to my variables; however, I just can't seem to figure out what is wrong... Here is the code.


    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    Dim FirstName As String
    Dim LastName As String
    Dim FullName As String

    FirstName = txtFirstName.Text
    LastName = txtLastName.Text
    FullName = FirstName & " " & LastName
    txtFirstName.Text = FullName

    txtFirstName.Text = FullName
    End Sub
    End Class


    The part that is giving me trouble is the line: txtLastName.Text and this is a screenshot of the Form.


    Thanks for any help on how to figure this out! Here is the website I'm learning from if the information I gave isn't enough to help. http://www.homeandlearn.co.uk/NET/nets1p14.html

  2. #2
    PowerPoster cicatrix's Avatar
    Join Date
    Dec 2009
    Location
    Moscow, Russia
    Posts
    3,654

    Re: Help fixing this error?

    From what I can see there's nothing wrong with your code provided the full name should be displayed in txtFirstName.
    You use this line twice for some reason:
    Code:
    txtFirstName.Text = FullName
    but it changes nothing.

    What exactly is the problem?

    P.S. You don't need FirstName and LastName variables in an example this simple. Just:
    Code:
     txtFirstName.Text = txtFirstName.Text & " " & txtLastName.Text
    Generally though your interface lacks the third textbox. A good user interface should not change values in the user input textboxes. Ideally, you should add another textbox txtFullName and display the result there.

  3. #3
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,764

    Re: Help fixing this error?

    "The part that is giving me trouble is the line: txtLastName.Text ..." What sort of trouble? Your code is different than the lesson you posted, FWIW.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

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