T
tshad
Using VB.Net VS 2003 I am getting the following message when I call my 2nd
constructor.
Too many arguments to 'Public Sub New()'.
I have 2 constructors:
**********************************
Public Sub New()
End Sub
Public Sub New(initial As Object)
first = initial
data = initial
End Sub
*********************************
But these are in my Abstract class. If I inherit from my Abstract Class,
does each class have to have its own constructor or can I use the same
constructor as my Abstract class. That doesn't appear to be the case here.
I am trying to set up a class that handles data to/from a database that will
tell me whether the value is null or not, what the inital value was and
whether it has been changed.
So I set up an abstract class that does most of the work and then I will
have a small object for each type of variable (string, integer, boolean,
decimal etc).
So how the classes look at the start is:
*******************************************
' Create to new variable types to handle nulls and track changes
' to standard variable types. This is for use with database variables.
' This will tell us if a vaiable has changed, give us the original and
current value,
' and tell us whether the current value and original value is/was null or
not.
imports System
imports System.IO
Namespace FtsData
MustInherit Class DataType
Private _first As Object
Private _data As Object
Private _changed As Boolean = False 'value changed from set
Private nullFirst As Boolean = False 'Was Null at start?
Private nullData As Boolean = False 'current data null
Public Sub New()
End Sub
Public Sub New(initial As Object)
first = initial
data = initial
End Sub
Public Function IsNull() As Boolean
return nullData
End Function
Public Function IsFirstNull() As Boolean
return nullFirst
End Function
Public Sub SetNull()
nullData = true
_data = ""
End Sub
Public Sub SetFirstNull()
nullFirst = true
_first = ""
End Sub
' Properties
Public Property First As Object
Get
return _first
End Get
Set
_first = value
End Set
End Property
Public Property Data As Object
Get
return _data
End Get
Set
_data = value
_changed = true
nullData = false
End Set
End Property
Public Property Changed as Boolean
Get
return _changed
End Get
Set
_changed = value
End Set
End Property
End Class
Class StringType : Inherits DataType
Private _first As String = "" 'original data
Private _data As String = "" 'current data
End Class
Class BooleanType : Inherits DataType
Private _first As Boolean = False 'original data
Private _data As String = False 'current data
End Class
End Namespace
*******************************************
I am calling it from my program as:
***************************************
Imports DBTypesVB.FtsData
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim temp As New StringType
Dim temp2 As New StringType("The 2nd String")
temp.Data = "This is a test"
End Sub
End Class
***************************************
When I set "temp" it works fine.
When I set "temp2" - I get the error.
It doesn't see the 2nd Constructor.
Do I have to take the constructors out of the Abstract class and put them in
each of the other classes?
Thanks,
Tom
constructor.
Too many arguments to 'Public Sub New()'.
I have 2 constructors:
**********************************
Public Sub New()
End Sub
Public Sub New(initial As Object)
first = initial
data = initial
End Sub
*********************************
But these are in my Abstract class. If I inherit from my Abstract Class,
does each class have to have its own constructor or can I use the same
constructor as my Abstract class. That doesn't appear to be the case here.
I am trying to set up a class that handles data to/from a database that will
tell me whether the value is null or not, what the inital value was and
whether it has been changed.
So I set up an abstract class that does most of the work and then I will
have a small object for each type of variable (string, integer, boolean,
decimal etc).
So how the classes look at the start is:
*******************************************
' Create to new variable types to handle nulls and track changes
' to standard variable types. This is for use with database variables.
' This will tell us if a vaiable has changed, give us the original and
current value,
' and tell us whether the current value and original value is/was null or
not.
imports System
imports System.IO
Namespace FtsData
MustInherit Class DataType
Private _first As Object
Private _data As Object
Private _changed As Boolean = False 'value changed from set
Private nullFirst As Boolean = False 'Was Null at start?
Private nullData As Boolean = False 'current data null
Public Sub New()
End Sub
Public Sub New(initial As Object)
first = initial
data = initial
End Sub
Public Function IsNull() As Boolean
return nullData
End Function
Public Function IsFirstNull() As Boolean
return nullFirst
End Function
Public Sub SetNull()
nullData = true
_data = ""
End Sub
Public Sub SetFirstNull()
nullFirst = true
_first = ""
End Sub
' Properties
Public Property First As Object
Get
return _first
End Get
Set
_first = value
End Set
End Property
Public Property Data As Object
Get
return _data
End Get
Set
_data = value
_changed = true
nullData = false
End Set
End Property
Public Property Changed as Boolean
Get
return _changed
End Get
Set
_changed = value
End Set
End Property
End Class
Class StringType : Inherits DataType
Private _first As String = "" 'original data
Private _data As String = "" 'current data
End Class
Class BooleanType : Inherits DataType
Private _first As Boolean = False 'original data
Private _data As String = False 'current data
End Class
End Namespace
*******************************************
I am calling it from my program as:
***************************************
Imports DBTypesVB.FtsData
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim temp As New StringType
Dim temp2 As New StringType("The 2nd String")
temp.Data = "This is a test"
End Sub
End Class
***************************************
When I set "temp" it works fine.
When I set "temp2" - I get the error.
It doesn't see the 2nd Constructor.
Do I have to take the constructors out of the Abstract class and put them in
each of the other classes?
Thanks,
Tom