Reputation: 26547
where can I find the default constructor of a windows form? I mean:
Public Sub New()
End Sub
I should say that I Use Visual Studio 2008 as my editor.
Upvotes: 3
Views: 7214
Reputation: 10931
A default (Public) constructor for any VB Class does not need to be defined explicity. In addition, in the .Designer.vb file, Forms include a DesignerGeneratedAttribute, which automatically adds a call to InitializeComponent
to the default constructor, and complains if your manually added constructor does not.
Upvotes: 1
Reputation: 20054
There is no default constructor as long as you did not write any. So add the code snippet of your question to the file MyForm.vb and you are happy. VS will typically add a call to InitializeComponent()
to it, which makes sense.
Upvotes: 0
Reputation:
It doesn't show up by default. You can declare one, and it will override the default constructor. In fact, as soon as you type in Public Sub New() and hit enter, VS should fill in a couple of lines of code, and you can add your code where needed.
Upvotes: 9