Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

This is weird, i´ve been workig on a project and now want to add a login section, after i created the login form i wanted do add a button to load that form, usually it worked but now it doesnt.
the error i get is:
'login'is a variable but is used like a type

the form is called login

thanks in advance

What I have tried:

C#
private void adminToolStripMenuItem_Click(object sender, EventArgs e)
{
    login login = new login();
    login.Show();
}
Posted
Updated 29-Nov-16 22:25pm
Comments
Philippe Mori 30-Nov-16 11:38am    
Not enough information is provided. You have to show the namespace and using declaration. Ensure that the appropriate assembly is referenced and that you have the appropriate using at the top of the file. It would also be a good idea to avoid using the same name and case for a type and a variable as it can cause additional problems if you don't do it the proper way.

1 solution

Just change a name of variable to something different. You are using type name as variable name.
 
Share this answer
 
Comments
Marc-IT 30-Nov-16 4:30am    
Thanks for the help,
Unfortunately i tried it already and no success.
It´s strange i used this code many times and no problems until now.
It´s driving me mad :\
In this same form i have many buttons witch open other forms with this same code
jimmson 30-Nov-16 4:33am    
So this is not working?
login form = new login();
form.Show();

What error message you get?
Marc-IT 30-Nov-16 4:46am    
The error i get is The type or namespace name 'login' could not be found (are you missing a using directive or an assembly reference?)
The reference is added and the form is created. I starting to think that the project got corrupted somehow.
jimmson 30-Nov-16 4:49am    
Try clean/rebuild or close/open Visual Studio. Also, it's not a good idea to name your types with lowercase first letter. Look at the naming guidelines: https://msdn.microsoft.com/en-us/library/ms229002(v=vs.110).aspx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900