Okay, so I have a textbox that I want to enable input in on a usercontrol. I do not want the textbox bound to a database, but I do want to do data validation inside the control, i.e. if it is an Int32 type 32.08 is not valid, if it is a decimal 32.08a is not valid.
I declared a private m_TypeCode as TypeCode, and can validate off that... But I want to overload the property DataValue with Int32, String, etc... which then sets m_TypeCode with the appropriate data type automatically, but the compiler doesn't seem to want to let me overload...
The message I get is: 'Public Property DataValue() As String' and 'Public Property DataValue() As Integer' cannot overload each other because they differ only by return types.
This is really more academic than practical. Any help is appreciated.
I declared a private m_TypeCode as TypeCode, and can validate off that... But I want to overload the property DataValue with Int32, String, etc... which then sets m_TypeCode with the appropriate data type automatically, but the compiler doesn't seem to want to let me overload...
Code:
Public Property DataValue() As String
Get
Return TextBox1.Text
End Get
Set(ByVal Value As String)
TextBox1.Text = Value
m_DataType = TypeCode.String
End Set
End Property
Public Property DataValue() As Int32
Get
Return System.Int32.Parse(TextBox1.Text.ToString())
End Get
Set(ByVal Value As Int32)
TextBox1.Text = Value.ToString
m_DataType = TypeCode.Int32
End Set
End Property
The message I get is: 'Public Property DataValue() As String' and 'Public Property DataValue() As Integer' cannot overload each other because they differ only by return types.
This is really more academic than practical. Any help is appreciated.