ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using CallByName for conversion function (https://www.excelbanter.com/excel-programming/314726-using-callbyname-conversion-function.html)

Nacho Nachev

Using CallByName for conversion function
 
Hello,

This is something that I should have known in the VB basics, but I didn't
and also it's not very Excel specific, but beacuse I am doing it in the
Excel context I guess it's relevant here.

I have the following call:

SomeFunction = CallByName(VBA, "CDbl", VbMethod, inputValue)

The problem is that I don't know the object in which the CDbl is defined.
Using VBA returns compiler error. I need to use this because "CDbl" will be
parameterized.

Thanks for you time,
Nacho



Rob Bovey

Using CallByName for conversion function
 
Hi Nacho,

If you check the Object Browser you'll discover that CDbl is not a
property or method of a class, so you can't run it using CallByName. I'm not
clear why you would want to do so anyway, since CDbl is a global function
that can be used directly from anywhere in a VBA program.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Nacho Nachev" wrote in message
...
Hello,

This is something that I should have known in the VB basics, but I didn't
and also it's not very Excel specific, but beacuse I am doing it in the
Excel context I guess it's relevant here.

I have the following call:

SomeFunction = CallByName(VBA, "CDbl", VbMethod, inputValue)

The problem is that I don't know the object in which the CDbl is defined.
Using VBA returns compiler error. I need to use this because "CDbl" will
be
parameterized.

Thanks for you time,
Nacho





Nacho Nachev

Using CallByName for conversion function
 
OK, I understand. I think I know what's the matter. Here's a quote from
MSND:

"These functions are compiled inline, meaning the conversion code is part of
the code that evaluates the expression. Execution is faster because there is
no call to a procedure to accomplish the conversion. Each function coerces
an expression to a specific data type."

I.e. no other normal way to accomplish my task, than creating a wrapper
class module for the conversion functions.

I need to do this because the conversion method to use is defined from an
external add-on.

Thanks a lot for your time,
Nacho


"Rob Bovey" wrote in message
...
Hi Nacho,

If you check the Object Browser you'll discover that CDbl is not a
property or method of a class, so you can't run it using CallByName. I'm

not
clear why you would want to do so anyway, since CDbl is a global function
that can be used directly from anywhere in a VBA program.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Nacho Nachev" wrote in message
...
Hello,

This is something that I should have known in the VB basics, but I

didn't
and also it's not very Excel specific, but beacuse I am doing it in the
Excel context I guess it's relevant here.

I have the following call:

SomeFunction = CallByName(VBA, "CDbl", VbMethod, inputValue)

The problem is that I don't know the object in which the CDbl is

defined.
Using VBA returns compiler error. I need to use this because "CDbl" will
be
parameterized.

Thanks for you time,
Nacho







Rob Bovey

Using CallByName for conversion function
 
Hi Nacho,

If you just want to call a function from another Excel add-in I would
suggest using Application.Run instead.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Nacho Nachev" wrote in message
...
OK, I understand. I think I know what's the matter. Here's a quote from
MSND:

"These functions are compiled inline, meaning the conversion code is part
of
the code that evaluates the expression. Execution is faster because there
is
no call to a procedure to accomplish the conversion. Each function coerces
an expression to a specific data type."

I.e. no other normal way to accomplish my task, than creating a wrapper
class module for the conversion functions.

I need to do this because the conversion method to use is defined from an
external add-on.

Thanks a lot for your time,
Nacho


"Rob Bovey" wrote in message
...
Hi Nacho,

If you check the Object Browser you'll discover that CDbl is not a
property or method of a class, so you can't run it using CallByName. I'm

not
clear why you would want to do so anyway, since CDbl is a global function
that can be used directly from anywhere in a VBA program.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Nacho Nachev" wrote in message
...
Hello,

This is something that I should have known in the VB basics, but I

didn't
and also it's not very Excel specific, but beacuse I am doing it in the
Excel context I guess it's relevant here.

I have the following call:

SomeFunction = CallByName(VBA, "CDbl", VbMethod, inputValue)

The problem is that I don't know the object in which the CDbl is

defined.
Using VBA returns compiler error. I need to use this because "CDbl"
will
be
parameterized.

Thanks for you time,
Nacho










All times are GMT +1. The time now is 05:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com