You might want to read up on "Default form instances". When you call Form2.Show, it actually calls My.Forms.Form2.Show(). As you will observe, the "My" Namespace is full of such handy shortcuts.
Personally, this is one of the things I dislike about Visual Basic or maybe I should say the direction in which Microsoft is taking VB. IIRC, this "feature" was removed during the transition from VB 6.0 to VB.NET and then reintroduced in VB 2005. And the "My" namespace should be called "MyA$$" !! :P On Jan 13, 8:11 pm, Dan King <[email protected]> wrote: > I am using VB.NET 2008. I have created two forms, Form1 and Form2. A > button on Form1 opens Form2. Although the way that I am doing this is > very unexpected. I always assumed you would have to create an object > and instantiate it, like this: > > Dim aForm2 As New Form2() > > And then show it like this: > > aForm2.Show() or aForm2.ShowDialog() > > Instead what I have found is that I can just call Show() and ShowDialog > () like they were static members of Form2 > > I have this code and it compiles and runs without error: > > Form2.Show() > > That code allows me to open Form2 within Form1 without create an > object and instantiating it first. Does anyone know why this is the > case and if .NET does some special form stuff that allows me to do it. > > Thanks for the help. > > Dan
