J jamie Aug 25, 2004 #1 Why can I not overload new() for a form? Maybe I am trying to do it wrong.? jamie
M Matt S Aug 25, 2004 #2 You can overload New for a form by adding another method named 'New' with different parameters than the original: --Code starts-- Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub Public Sub New(ByVal strMessage As String) Me.New() ' Add any additional code here End Sub --Code Ends-- You should only use the Overloads keyword if you are overloading an inherited method. Remember to make sure your new 'New' method calls MyBase.New and InitializeComponent otherwise the form will not load correctly. Hope this helps.
You can overload New for a form by adding another method named 'New' with different parameters than the original: --Code starts-- Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub Public Sub New(ByVal strMessage As String) Me.New() ' Add any additional code here End Sub --Code Ends-- You should only use the Overloads keyword if you are overloading an inherited method. Remember to make sure your new 'New' method calls MyBase.New and InitializeComponent otherwise the form will not load correctly. Hope this helps.
H Herfried K. Wagner [MVP] Aug 25, 2004 #3 * "jamie said: Why can I not overload new() for a form? Maybe I am trying to do it wrong.? Click to expand... \\\ Public Sub New() ... End Sub Public Sub New(ByVal UserName As String) MyBase.New() ... End Sub /// What's the problem?
* "jamie said: Why can I not overload new() for a form? Maybe I am trying to do it wrong.? Click to expand... \\\ Public Sub New() ... End Sub Public Sub New(ByVal UserName As String) MyBase.New() ... End Sub /// What's the problem?
J jamie Aug 25, 2004 #4 Oh.... Well... You dont have to make it that simple. That takes all the fun away. Thanks jamie