I was wondering if it was possible to reference a property or method by the class itself. That property would depend on the data type of the passed value.
I am thinking of something similar to what you can do with VB6. I have never really played around with VB6 for at least 5 or 6 years. I have more recently (in the past 4 years) read about this in a VB.NET (it compared .net to the classic VB6) book. BUT I seem to remember that VB6 and/or VBA allowed you to assign a textfield’s text by referencing the class itself?? So it would saving you from typing this:
textfield1.text = "your text"
And you could refer to the text property with:
textfield1 = "your text"
Can I use something like operator overloading to achieve this or is this just not recommended code practice these days?
The idea is, I have a class that would give you the same behaviour as a data type like an integer, double or string apart from it sets a boolean variable internally to state that the value has been changed.
[quote=142023:@Norman Palardy]You won’t be able to make this work
The name of the control is basically reserved and so trying to make a new method of your own that takes on the same name will not be possible[/quote]
Okay, thanks. I was not planning on using this like I was showing in the example so that will not be a problem.
[quote=142030:@Michel Bujardet]The closest you can get is to use a string Computed Property called TextArea1_ and use set and get to access TextArea1.Text.
That said, unless you plan on writing 2000 lines of code around TextArea1.Text, it probably is safer to keep the traditional notation.[/quote]
I know this. I could decide for myself how I wanted to distinguish the original from this. As I said, it is just an example and I do not plan to do this.