C
Colin McGuire
Hi, I have a class with lots of constructors - one is shown below
Public Sub New(ByVal rows As Integer, ByVal columns As Integer)
InitializeComponent()
'And code in here that sets instance variables,
'and does calculations based on rows and columns passed
'in in the constructor, and lots more.
End Sub
Another of my constructors has no parameters, and there are various
other
constructors that receive, for example, Point etc. But what I want to
do is
call one constructor New from another constructor New so I don't have
to reproduce the same code many times, or put it in a separate
procedure and call it from each New(..)
Here is what I am wanting to do, but the compiler is having none of it
!
Public Class test
Inherits System.Windows.Forms.Form
Public Sub New(ByVal rows As Integer, ByVal columns As Integer)
InitializeComponent()
'And code in here that sets instance variables,
'and does calculations based on rows and columns passed
'in in the constructor, and lots more.
End Sub
Public Sub New()
Dim defaultRows As Integer=2
Dim defaultColumns As Integer=10
Call New(defaultRows,defaultColumns)
End Sub
'More methods/code etc
End Class
Can someone cast their eye over this and help me along with the
correct syntax (the line "Call New(defaultRows,defaultColumns" is the
line the compiler balks at).
Thank you
Colin
Public Sub New(ByVal rows As Integer, ByVal columns As Integer)
InitializeComponent()
'And code in here that sets instance variables,
'and does calculations based on rows and columns passed
'in in the constructor, and lots more.
End Sub
Another of my constructors has no parameters, and there are various
other
constructors that receive, for example, Point etc. But what I want to
do is
call one constructor New from another constructor New so I don't have
to reproduce the same code many times, or put it in a separate
procedure and call it from each New(..)
Here is what I am wanting to do, but the compiler is having none of it
!
Public Class test
Inherits System.Windows.Forms.Form
Public Sub New(ByVal rows As Integer, ByVal columns As Integer)
InitializeComponent()
'And code in here that sets instance variables,
'and does calculations based on rows and columns passed
'in in the constructor, and lots more.
End Sub
Public Sub New()
Dim defaultRows As Integer=2
Dim defaultColumns As Integer=10
Call New(defaultRows,defaultColumns)
End Sub
'More methods/code etc
End Class
Can someone cast their eye over this and help me along with the
correct syntax (the line "Call New(defaultRows,defaultColumns" is the
line the compiler balks at).
Thank you
Colin