here is my dilemma (or misunderstanding most likely):
I have a main form called "mainmodule" which is set up to run as a singleton.
Now what I want to do is make another class which inherits the mainmodule class.
I'm not sure if that is how it should be properly done, but in the long run all I want is multiple "submodules" that inherit the "mainmodule" so that I will not have to implement the singleton methods on each "submodule".
I assume my issue is with how the "instanced()" method is written, as it returns a new "mainmodule" form and not that of the subform.
I have a main form called "mainmodule" which is set up to run as a singleton.
Now what I want to do is make another class which inherits the mainmodule class.
I'm not sure if that is how it should be properly done, but in the long run all I want is multiple "submodules" that inherit the "mainmodule" so that I will not have to implement the singleton methods on each "submodule".
VB.NET:
Public Class mainmodule
Inherits System.Windows.Forms.Form
Public components As System.ComponentModel.IContainer
Private Shared instance As mainmodule
Public Shared Function Instanced() As mainmodule
If instance Is Nothing Then
instance = New mainmodule
End If
Return instance
End Function
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
instance = Nothing
End Sub
Public Sub New()
End Sub
End Class
VB.NET:
Public Class submodule
Inherits mainmodule
Protected Sub New()
MyBase.New()
me.Text = "subform singleton"
End Sub
End Class
VB.NET:
Windows.Forms.Application.Run(submodule.Instanced())
I assume my issue is with how the "instanced()" method is written, as it returns a new "mainmodule" form and not that of the subform.