Question What is the difference?

Budius

Well-known member
Joined
Aug 6, 2010
Messages
137
Location
UK
Programming Experience
3-5
I know it will sound like a dull question, but, coming from a VB6 and C in micro controllers it might be quite reasonable:

what is the difference between:
VB.NET:
Expand Collapse Copy
frm_main.show()
to
VB.NET:
Expand Collapse Copy
dim f as new frm_main
f.show

?

thanks
 
It is exactly the same as in VB6, first is using the default form instance, second is creating a new form instance. If you only need a single instance of a form at any given time in program flow use the default instance for simplicity. The default instance also makes it easier to reference a different form without the need to pass/maintain the reference.
 
I guess I never created an instance on VB6, only the default... lol... unfortunately the applications I'm coding are by their nature the least reusable it gets.
Anyway, I though that would be the answer but, as everybody example is always using dim f as new frm_whatever, f.show() I was not sure I was programming something dumb.

thanks.
 
Back
Top