October 17th, 2013, 09:00 PM
Visual Basic Coding Help: Why Is This Error Here?
Me again. Didn't think I was gonna have to post again so soon, but I've ran into a problem with another project of mine. What I'm trying to do is make a program that provides a text box for entering a person's first and last name (with a space in between, of course) with a Click event procedure that displays the name in reverse with a comma and a space in between the first and last name.
I thought for sure I had this in the bag, but before I could even debug the program I get this error:
Value of type 'String' cannot be converted to 'System.Windows.Forms.Label'. 40 21
It's been a while since I did these so I can't, for the life, figure out how to resolve this error.
Here's the code I'm using, and, again, I'm using Microsoft Visual Basic 2010 Express.
Option Explicit On
Option Strict On
Public Class MainForm
Private Sub exitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles exitButton.Click
Private Sub nameTextBox_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles nameTextBox.Enter
Private Sub nameTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles nameTextBox.TextChanged
nameLabel.Text = String.Empty
Private Sub reverseButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles reverseButton.Click
Dim firstName As String
Dim lastName As String
Dim numberLast As Integer
Dim numberFirst As Integer
Dim input As String
Dim isConverted As Boolean
Dim index As Integer
input = nameTextBox.Text
index = input.IndexOf(" ")
firstname = input.Substring(0, index)
lastname = input.Substring(index + 1)
nameLabel = lastName + ", " + firstName
October 18th, 2013, 03:01 AM
Re: Visual Basic Coding Help: Why Is This Error Here?
Have you tried :
nameLabel.Text = lastName + ", " + firstName
Click Here to Expand Forum to Full Width