6

I am actually studying and working on VB.NET. My school is using VS2010, and I professionally use VS2012. When I have to call a windows form in an Mdicontainer in VS2010, I just use its class name, like for example:

FormX.MdiParent = Me

FormX.Show()

But when i use VS2012, it seems I have to create an instance of my mdichild, just like this:

Dim form As New FormX()

form.MdiParent = Me

form.Show()

My question is: is it just me doing wrong or VS has changed the way we use WinForms?

SSS
  • 4,463
  • 1
  • 22
  • 44
Yonn Trimoreau
  • 541
  • 6
  • 23
  • 6
    Wow, have they really removed this VB 6 holdover from VB.NET 11? That would be fantastic! – Cody Gray Aug 20 '13 at 13:39
  • 1
    Wow, my teachers are outdated.. But it's pretty handy ! – Yonn Trimoreau Aug 20 '13 at 13:43
  • 1
    @CodyGray Looks like not, I just tested it and default instances work in vs2012. – John Koerner Aug 20 '13 at 13:43
  • @YonnTrimoreau There must be something else going on, as I just tested it with a two form app and was able to do a `Form2.Show()` – John Koerner Aug 20 '13 at 13:44
  • 5
    Then the answer is "no, something else is wrong", and "yes, your teachers are outdated, [that has always been the wrong way to do it in VB.NET](http://stackoverflow.com/questions/6832962/what-is-the-difference-between-the-following-methods-of-showing-forms)". – Cody Gray Aug 20 '13 at 13:45
  • Ok, thanks, problem resolved : never ever study programming in France ;) – Yonn Trimoreau Aug 20 '13 at 13:52
  • 2
    possible duplicate of [There is a Default instance of form in VB.Net but not in C#, WHY?](http://stackoverflow.com/questions/4698538/there-is-a-default-instance-of-form-in-vb-net-but-not-in-c-why) – Hans Passant Aug 20 '13 at 14:28

1 Answers1

1

VS2012 VB.NET does have default instances, just like in VS2010. Most likely you have defined a custom Sub New() with a parameter list, e.g. Sub New(a As Integer). When this is the case no default instance is generated, you need to explicitly create the form.

SSS
  • 4,463
  • 1
  • 22
  • 44