Class not instantiated

lazlo2000

New member
Joined
Dec 3, 2012
Messages
2
Programming Experience
Beginner
VB.NET:
 Option Strict Off
 Option Explicit On
  '''' ABOUT FORM
 Friend Class FrmAbout
     Inherits Form
      '''' LOAD THE FORM
     Private Sub FrmAboutLoad(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles MyBase.Load
         Label1.Text = "Version " & My.Application.Info.Version.Major & "." & My.Application.Info.Version.Minor & "." & My.Application.Info.Version.Revision
     End Sub
      '''' QUERY UNLOAD EVENT
     Private Sub FrmMainFormClosing(ByVal eventSender As Object, ByVal eventArgs As FormClosingEventArgs) Handles Me.FormClosing
         Me.Hide()
         frmMain.Show()
      End Sub
 End Class
How do I instantiate the class?
 
Last edited by a moderator:
You can use the default instance if you only want to use one instance at a time, which means simply using the class name to refer to an instance, e.g.
VB.NET:
FrmAbout.ShowDialog()
Personally, I'm not a big fan of that option, despite its being easier. I prefer to treat forms just like every other type, which means invoking a constructor using the New keyword, e.g.
VB.NET:
Using aboutBox As New FrmAbout
    aboutBox.ShowDialog()
End Using
 
I think I got it now, whenever I want to bring up the frmAbout dialog I just have

FrmAbout.ShowDialog()
 
Last edited:
Back
Top