I've started doing some basic win forms work in VB 2010 and I'm really bothered by the default instance feature. Is there a way I can disable it entirely and just use the classes like ordinary classes?
Asked
Active
Viewed 230 times
1
-
No. It is a feature added to make it easier for hobbyists and those resisting the change from VB6 to NET. If you dont like it, dont use it. – Ňɏssa Pøngjǣrdenlarp Nov 04 '14 at 12:57
-
Plutonix is right - you can simply ignore it in your code. – DWRoelands Nov 04 '14 at 13:06
-
1Congratulations on recognizing it as a horrible feature! VB programmers who use it without realizing what they're doing are doing themselves no favors. – Dave Doknjas Nov 04 '14 at 15:04
-
1@Plutonix it's hard to "not use" sometimes. It shows up in all my intellisense and doesn't break my build if I make a mistake. – just.another.programmer Nov 04 '14 at 17:05
-
Just avoid to name variables as a types or closely to them. – Fabio Nov 04 '14 at 17:10
1 Answers
0
Add a parameter to the form's constructor. That will prevent the default instance being created. You will need to have a call to InitializeComponent to layout the controls.
Sub New(junk As Object)
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
End Sub

SSS
- 4,807
- 1
- 23
- 44