Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The class Form1 can be designed, but is not the first class in the file[...]

I'm a newbie on vb.net, and I was in progress with my first application... and found some example code in the msdn so I just replaced my Form1.vb file content with the content from the MSDN. When I roll back the changes, and tried to compile my old code then hundreds of errors appeared, and when I switch to the Form1[Design] tab I see this:

The class Form1 can be designed, but is not the first class in the file. Visual Studio requires that designers use the first class in the file. Move the class code so that it is the first class in the file and try loading the designer again.

I'm really new on vb.net and the visual studio itself, and I dont know what to do in this case, is my work destroyed or what?

like image 853
Scott Avatar asked Nov 22 '12 20:11

Scott


2 Answers

That's because you added some class or other code above the class definition in form1.vb. Remove that.

like image 52
Federico Berasategui Avatar answered Nov 08 '22 23:11

Federico Berasategui


What worked for me is editing both Form1.vb and Form1.Designer.vb and placing at the beginning of both files: Namespace Whatever and at the end of both files: End Namespace. The "Whatever" can be any name not already used in the program (or the name of an existing Namespace that you're already using).

like image 1
Yaakov Avatar answered Nov 09 '22 00:11

Yaakov