Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

overload property in usercontrol 1

Status
Not open for further replies.

despierto

Programmer
Jun 25, 2004
39
US
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...
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.
 
Right, the method signatures must differ by more than just the return type.

Whidbey will have this ability, or so I've heard.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Ahhh... Well, this is a pain. So now I'm returning an object, and seeing what type of object it is, but that seems like so much overhead, I may just go back to returning a string, and having the calling application determine what it is.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top