I am trying to create a series of overloaded methods that all take the same parameters EXCEPT the one is a different datatype in each method…
This is working fine for all but this
Public Sub AddProperty(Name As String,defaultValue As String,readonly As Boolean=False)
..... code ....
End Sub
Public Sub AddProperty(Name As String,defaultValue As String(),readonly As Boolean=False)
.... code....
End Sub
The first passes a scalar string, while the second passes an ARRAY
If I do NOT add the ARRAY version, its fine
but when I do I get TWO errors
the first is tagged as “DUPLICATE METHOD DEFINATION”
the second is marked as “SYNTAX ERROR”
The “duplicate” I would understand if the signatures were the same… but I would have thought the () would have been ok
And I fail to see the syntax error in the second
Edit: Also, your syntax error - arsDefault() as String not arsDefault as String()[/quote]
Not sure how that is any different… since you need to specifiy the datatype of the param array.
and I have an overload for DOUBLE, STRING, BOOLEAN, FOLDERPATH etc… etc… and only one that passes an Array
With the ParamArray the number of values passed can be variable. I believe it would have to be the last paramter for the method, but you would no longer need to have overloaded methods.
AddProperty("Prop Name", false, "Default Value")
and
AddProperty("Prop Name", false, "Default Value 1", "Default Value 2", "Default Value 3")
could both run the same code for single string values or string arrays.
I wasn’t aware you were overloading with other data types though. Do as you see best fit for the use!
sub add(name as string, index as integer)
sub add(name as string,index as integer, paramarray list() as string)
these signatures ARE DIFFERENT, it does compile without error
but at runtime
[code]
add(“fred”,14)
add(“barney”,3,“a”,“b”,“c”)
[code]
BOTH call the paramarray version
The first is to “insert an INTEGER called ‘FRED’ with a value of 14”
the second is to “insert a String Array [“a”,“b”,“c”] called “BARNEY” with a current index of 3”
there are other versions of ADD where the 2nd value is BOOLEAN, COLOR, DOUBLE etc…
but this is the only one where the first TWO parameters are the same datatype
and I thought overloads were based on the ENTIRE signature not being the same