I looked at the example, but I don't get it. It's possible to add, subtract, multiply and divide udt declared variables against each other, right? I don't really understand how to make it work.
option explicit
Type Vector3D
X as Single
Y as Single
Z as Single
End Type
function AddVector(Vec1 as Vector3D, Vec2 as Vector3D, Sum as Vector3D)
Sum.X = Vec1.X + Vec2.X
Sum.Y = Vec1.Y + Vec2.Y
Sum.Z = Vec1.Z + Vec2.Z
end function
Dim as Vector3D a = (1, 2, 3), b = (4, 5, 6), c
AddVector(a, b, c)
print "c = ("; c.X;","; c.Y; ","; c.Z; " )"
sleep
option explicit
type Vector3D
X as single
Y as single
Z as single
end type
function AddVector(Vec1 as Vector3D, Vec2 as Vector3D) as Vector3D
dim as Vector3D Result
Result.X = Vec1.X + Vec2.X
Result.Y = Vec1.Y + Vec2.Y
Result.Z = Vec1.Z + Vec2.Z
AddVector = Result
end function
dim as Vector3D A = (1, 2, 3), B = (4, 5, 6), C
C = AddVector(A, B)
print "c = ("; C.X; ","; C.Y; ","; C.Z; " )"
sleep
Wonderful! Now I can write all my complex functions this way ;-)