Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
User Defined Types and Overloaded Operators
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, |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
User Defined Types and Overloaded Operators
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, |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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, |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
User Defined Types and Overloaded Operators
"Chip Pearson" wrote: 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. It is my understanding that Excel 2007 allows one to develop Add-ins using C++. Since C++ allows the overloading of mathematical operators such as "+", can one overload Excel's mathematical operators? Although I am interested in overloading functions, I am more interested in overloading the mathematical operators which are used by most user when writing formulas. For example, column A B C row 1 "Widget1" "Widget2" = A1+A2 result "someresult" where "someresult" is based upon the logic contained within the overloaded operator "+". Thank You, -- 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, |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
User Defined Types and Overloaded Operators
It is my understanding that Excel 2007 allows one to develop Add-ins using C++. XLA-type add-ins must be written in VBA. Since Excel 2000, Excel has supported COM Add-Ins and since 2002 has supported Automation Add-Ins, each of which can be written in any language that supports COM, including C++. In Excel 2003 and 2007, you can also write add-ins and class libraries in any NET language you like. Internal to a C++ or NET add-in, you can do any sort of overloading you want, in the sense that "overload" means in C++. However, you cannot overload any operators in a worksheet formula. For example, there is no way to change the meaning of the '+' operator in a formula to add numbers and concatenate strings. Nor can you create your own operators. Overloading is really a function of the compiler as much as it is of the runtime libraries, and you can't use features of the C++ compiler to work with Excel formula. It would certainly be nice, but sadly can't be done. -- Cordially, Chip Pearson Microsoft MVP - Excel, 10 Years Pearson Software Consulting www.cpearson.com (email on the web site) "eq" wrote in message ... "Chip Pearson" wrote: 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. It is my understanding that Excel 2007 allows one to develop Add-ins using C++. Since C++ allows the overloading of mathematical operators such as "+", can one overload Excel's mathematical operators? Although I am interested in overloading functions, I am more interested in overloading the mathematical operators which are used by most user when writing formulas. For example, column A B C row 1 "Widget1" "Widget2" = A1+A2 result "someresult" where "someresult" is based upon the logic contained within the overloaded operator "+". Thank You, -- 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, |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Checking user defined types for Nothing | Excel Programming | |||
subs or functions with user defined types | Excel Programming | |||
User-defined data type; Error: Only User-defined types... | Excel Programming | |||
Unable to add user-defined data types to a collection | Excel Programming |