View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default User Defined Types and Overloaded Operators

yes it is possible to overload excel. but not excel specificly. you are
limited by available resorces ie hard drive size, memory, processer speed,


I don't think that is what he means by overloading. An example of the
overloading in the context of the original question would be to have two (or
more) functions with the same name but that take a different type(s) and
number of input parameters. As a very simple example,

Public Function MyTest(D As Double)
' code
End Function

Public Function MyTest(S As String)
' code
End Function

If overloading were possible in VBA, the compiler would automatically select
which MyTest function to use based on the data type of the parameter. Thus

R = MyTest(123.456)
' and
R = MyTest("abcd")

would actually call two different MyTest procedures, each selected by the
data type of the input parameter.

Overloading an operator mean to have one symbol (e.g., '+') whose behavior
depends on the data types that are being processed by the '+' operation. (In
this example, the '+' is in fact overloaded within VBA: if used with
strings, "abc" + "def", it acts as a & concatenator and when used with
numbers it acts as the normal numeric addition operator.

Alas, no overloading is possible in VBA.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)



"FSt1" wrote in message
...
hi
yes it is possible to overload excel. but not excel specificly. you are
limited by available resorces ie hard drive size, memory, processer speed,
other, ect.
yes, you can write your own functons. they are called UDFs(User Defined
Functions)
function something()
some code
end function

good for creating special formula or other functions for the user. do a
google on excel functions. they are fairly easy but can get rather
complicated depending.

Regards
FSt1
"eq" wrote:

Currently Excel allows operands of various types to be used in formulas.
Operands such as Number, Cell References, Names, Labels, and Functions
are
among those currently allowed. I am interested in whether or not it is
possible to build a user defined type, essentially a string of
concatenated
chunks of information. In addition, is it possible to overload the
Excel's
calculation operators?

Thank You,