T
tshad
In VS 2003, I am setting up an abstract class that is setting up classes for
each datatype of VB.Net (as well as C#).
I am trying to set it up so that most of the work is done in the Abstract
Class. It seems to work pretty well. I have the actual data memory
variables stored as an object as each class will use it as a different type
of object (not sure if this is a problem).
The system can tell if the variable is a string, boolean or integer pretty
well by the initial settings.
But it has a problem with decimal, singles and doubles.
When looking at the variables as they are created in the watch window:
*********************************************
Dim temp As New StringType
Dim temp2 As New StringType("The 2nd String")
Dim tempBool As New BooleanType
Dim tempBool2 As New BooleanType(True)
Dim tempInteger As New IntegerType
Dim tempInteger2 As New IntegerType(25)
Dim tempDecimal As New DecimalType
Dim tempDecimal2 As New DecimalType(15)
Dim tempSingle As New SingleType
Dim TempSingle2 As New SingleType(12.15)
Dim TempDouble As New DoubleType
Dim TempDouble2 As New DoubleType(15.23)
**********************************************
The system thinks the variables in the DecimalType class is an integer and
the variables in the SingleType and DoubleType class are Doubles.
Here is the Class so far:
********************************************
' 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
Protected _first As Object
Protected _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 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
Public Sub New()
_first = "" 'original data
_data = "" 'current data
End Sub
Public Sub New(initial As Object)
_first = initial
_data = initial
End Sub
End Class
Class IntegerType : Inherits DataType
Public Sub New()
_first = 0 'original data
_data = 0 'current data
End Sub
Public Sub New(initial As Object)
_first = 0
_data = 0
End Sub
End Class
Class IntType : Inherits DataType
Public Sub New()
_first = 0 'original data
_data = 0 'current data
End Sub
Public Sub New(initial As Object)
_first = initial
_data = initial
End Sub
End Class
Class BoolType : Inherits DataType
Public Sub New()
_first = False 'original data
_data = False 'current data
End Sub
Public Sub New(initial As Object)
_first = initial
_data = initial
End Sub
End Class
Class BooleanType : Inherits DataType
Public Sub New()
_first = False 'original data
_data = False 'current data
End Sub
Public Sub New(initial As Object)
_first = initial
_data = initial
End Sub
End Class
Class DecimalType : Inherits DataType
Public Sub New()
_first = 0 'original data
_data = 0 'current data
End Sub
Public Sub New(initial As Object)
_first = initial
_data = initial
End Sub
End Class
Class SingleType :Inherits DataType
Public Sub New()
_first = 0.0 'original data
_data = 0.0 'current data
End Sub
Public Sub New(initial As Object)
_first = initial
_data = initial
End Sub
End Class
Class DoubleType :Inherits DataType
Public Sub New()
_first = 0.0 'original data
_data = 0.0 'current data
End Sub
Public Sub New(initial As Object)
_first = initial
_data = initial
End Sub
End Class
End Namespace
********************************************
I could initally set them up in the classes, something like:
************************************
Class DoubleType :Inherits DataType
Private _first As Decimal
Private _data As Decimal
Public Sub New()
_first = 0.0 'original data
_data = 0.0 'current data
End Sub
Public Sub New(initial As Object)
_first = initial
_data = initial
End Sub
**********************************
But then the Properties in the Abstract class wouldn't be able to access
them. Actually as set up here the SetNull and SetFirstNull methods are not
correct as the variables are not always strings.
Do I have to set each each variable type in each class instead of an object
in the Abstract class?
If so, is there a way to get the Properties in the Abstract class to access
them?
Thanks,
Tom
each datatype of VB.Net (as well as C#).
I am trying to set it up so that most of the work is done in the Abstract
Class. It seems to work pretty well. I have the actual data memory
variables stored as an object as each class will use it as a different type
of object (not sure if this is a problem).
The system can tell if the variable is a string, boolean or integer pretty
well by the initial settings.
But it has a problem with decimal, singles and doubles.
When looking at the variables as they are created in the watch window:
*********************************************
Dim temp As New StringType
Dim temp2 As New StringType("The 2nd String")
Dim tempBool As New BooleanType
Dim tempBool2 As New BooleanType(True)
Dim tempInteger As New IntegerType
Dim tempInteger2 As New IntegerType(25)
Dim tempDecimal As New DecimalType
Dim tempDecimal2 As New DecimalType(15)
Dim tempSingle As New SingleType
Dim TempSingle2 As New SingleType(12.15)
Dim TempDouble As New DoubleType
Dim TempDouble2 As New DoubleType(15.23)
**********************************************
The system thinks the variables in the DecimalType class is an integer and
the variables in the SingleType and DoubleType class are Doubles.
Here is the Class so far:
********************************************
' 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
Protected _first As Object
Protected _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 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
Public Sub New()
_first = "" 'original data
_data = "" 'current data
End Sub
Public Sub New(initial As Object)
_first = initial
_data = initial
End Sub
End Class
Class IntegerType : Inherits DataType
Public Sub New()
_first = 0 'original data
_data = 0 'current data
End Sub
Public Sub New(initial As Object)
_first = 0
_data = 0
End Sub
End Class
Class IntType : Inherits DataType
Public Sub New()
_first = 0 'original data
_data = 0 'current data
End Sub
Public Sub New(initial As Object)
_first = initial
_data = initial
End Sub
End Class
Class BoolType : Inherits DataType
Public Sub New()
_first = False 'original data
_data = False 'current data
End Sub
Public Sub New(initial As Object)
_first = initial
_data = initial
End Sub
End Class
Class BooleanType : Inherits DataType
Public Sub New()
_first = False 'original data
_data = False 'current data
End Sub
Public Sub New(initial As Object)
_first = initial
_data = initial
End Sub
End Class
Class DecimalType : Inherits DataType
Public Sub New()
_first = 0 'original data
_data = 0 'current data
End Sub
Public Sub New(initial As Object)
_first = initial
_data = initial
End Sub
End Class
Class SingleType :Inherits DataType
Public Sub New()
_first = 0.0 'original data
_data = 0.0 'current data
End Sub
Public Sub New(initial As Object)
_first = initial
_data = initial
End Sub
End Class
Class DoubleType :Inherits DataType
Public Sub New()
_first = 0.0 'original data
_data = 0.0 'current data
End Sub
Public Sub New(initial As Object)
_first = initial
_data = initial
End Sub
End Class
End Namespace
********************************************
I could initally set them up in the classes, something like:
************************************
Class DoubleType :Inherits DataType
Private _first As Decimal
Private _data As Decimal
Public Sub New()
_first = 0.0 'original data
_data = 0.0 'current data
End Sub
Public Sub New(initial As Object)
_first = initial
_data = initial
End Sub
**********************************
But then the Properties in the Abstract class wouldn't be able to access
them. Actually as set up here the SetNull and SetFirstNull methods are not
correct as the variables are not always strings.
Do I have to set each each variable type in each class instead of an object
in the Abstract class?
If so, is there a way to get the Properties in the Abstract class to access
them?
Thanks,
Tom