Overloading in VB / VBA - TechRepublic
General discussion
February 25, 2001 at 04:43 AM
sankulpune

Overloading in VB / VBA

by sankulpune . Updated 25 years, 4 months ago

Hello,

I was just going through the book (I just started learning Java), The Complete Reference Java 2 by Naughten & Schildt. One sentence in the book stuck me: ‘In languages that do not support method overloading, each method must be given a unique name.’ It then mentions that ‘C’ has three functions ‘abs(integer)’, ‘labs(long)’, ‘fabs(float)’ for for calculating absolute values.
It then suddenly stuck me that in VB & VBA, even though they do not support overloading, we use only one function ‘abs(number)’, and not threee, for for calculating absolute values. How is this possible.
On further thinking on this, I realised that VB/VBA uses variant to overload ‘methods’.
The price of this ‘simplification’we pay is extra bytes to save the value of the variable and additional processing to check the type(integer/long/double) of value stored in the variant.
Is this one of the reasons why VB/VBA is, in execution, slower and inefficient than languages like Java & C++?

I am not a Software Engineer by training. Hence I am putting this question to the discussion group.

SanganakSakhs

This discussion is locked

All Comments