Question String cannot be converted to system.windows.forms.label

kusohead

New member
Joined
Mar 31, 2010
Messages
4
Programming Experience
Beginner
Hi I am new to this community, sorry if I am posting this thread in the wrong forum

I am writing a program for my A-level coursework
But for some reason I got this build error



this has never occurred to me before, I have no idea why I can't use string for the name of my form...

Can anybody help?

Thanks in advances!
 
Me.Name is a Label Control. You are trying to assign a String to it.

I'm assuming you want the Label to display "Calender"?

If so try Me.Name.Text = "Calendar"
 
Do NOT use the word, "Name" as a variable name. It is (sort of a keyword) designated as a property for all the control objects on your form. Just use a word like "nom" or "myname" for your variable.
 
Call it a lesson in naming conventions. Use txtName; txt- for textbox, lsb- for listbox, cb- for combobox, lb- for label, etc... Now it is easy to find you controls, and you won't have the above problem.
 
Me.Name is a Label Control. You are trying to assign a String to it.

I'm assuming you want the Label to display "Calender"?

If so try Me.Name.Text = "Calendar"

I have tried that, it allowed me to run the program once, and then whenever I save it, it changes itself back again...

I have no idea what is going on, I have tried to change the parameter to something absolutely random like "ggg" etc. but it doesn't solves the problem:eek:
 
pls show line 259 the line of conflicting code thx
 
There is a Label control in form that you have named 'Name'. This is what the warning on second line in Error window says (problem in line 287). When you add controls to form IDE adds a WithEvents variable with same name as the Control.Name (the 'Friend WithEvents variablename As controlType' listing). So in 'Calendar' (form Name) section of InitializeComponent method when the form itself is configured the Me.Name points to this Label variable instead of the forms Name property that it is supposed to. In form Designer you can select the Label named "Name" and change the name to correct the issue.
 
There is a Label control in form that you have named 'Name'. This is what the warning on second line in Error window says (problem in line 287). When you add controls to form IDE adds a WithEvents variable with same name as the Control.Name (the 'Friend WithEvents variablename As controlType' listing). So in 'Calendar' (form Name) section of InitializeComponent method when the form itself is configured the Me.Name points to this Label variable instead of the forms Name property that it is supposed to. In form Designer you can select the Label named "Name" and change the name to correct the issue.

Wow, now I got it working :)
Thank you very much, JohnH! ;)
 
Back
Top