Code: Select all
Declare Function SUM Overload (A As Integer,B As Integer, MyArrElement as Integer ) As Integer
Declare Function SUM Overload (A As Single,B As Single, MyArrElement as Single ) As Single
Declare Function SUM Overload (A As Single,B As Single, MyArrElement as String ) As String
Function SUM (A As Integer,B As Integer, MyArrElement As Integer ) As Integer
Print @MyArrElement & " this one is worse than useless : ByRef is NOT supported !.." & chr(10) & " But MyArrElement (Byte) is overloaded "
Function=A+B+MyArrElement
End Function
Function SUM (A As Single,B As Single, MyArrElement As Single ) As Single
Function=A+B+MyArrElement
End Function
Function SUM (A As Single,B As Single, MyArrElement As String ) As String
Print @MyArrElement & " Whereas ByRef & ByVal access on string arrays element are supported !"
Function="" ' MyArrElement
End Function
Dim As Integer A,B
Dim As Single A1,B1
Dim As Byte array()
Redim array(1)
'Dim array(1) As Byte
array(0)=2
array(1)=1
A=2
B=3
A1=2.
b1=3.
Print "Function overload test -----------------------"
Print
Print @array(0) & " = address of array(0)"
Print SUM(A,B, array(0) )
Print SUM (A1,B1, array(0) )
Dim array_2(1) As String
array_2(0)="String value"
Print @array_2(0)
Print SUM (A1,B1, array_2(0) )
'sleep
Type Test
Dim toto as uByte
Public:
Declare Property Set(ByRef MyArrElement as Integer ) As Integer
Declare Property Set(ByRef MyArrElement as Single ) As Single
Declare Property Set(ByRef MyArrElement as String ) As String
End Type
Property Test.Set(ByRef MyArrElement as Integer ) As Integer
Print @MyArrElement & " this one is usefull : ByRef is supported" & chr(10) & " (but MyArrElement (Byte) isn't 'auto-overloaded')."
Return 1
End Property
Property Test.Set(ByRef MyArrElement as Single ) As Single
Print @MyArrElement : Return 1
End Property
Property Test.Set(MyArrElement as String ) As String
Print @MyArrElement : Return ""
End Property
Dim array_3(2) As Integer
array_3(0)=1
Dim MyTest As Test
Print
Print "Property overload test -------------------"
Print
MyTest.Set( array_3(0) )
sleep
system