From: l h on 25 Feb 2010 14:50 I'm new to VB/VBA and calling functions in external DLLs from VB/VBA. If I declare a variable in VBA, assign a value and then call a C++ function in a DLL, is any type checking down between VBA and the C++ function? So if I declare a Long identifier in VBA and then call a function that expects an enum type in C++, will the call be flagged for type mismatch? Thanks. Les
From: Chip Pearson on 25 Feb 2010 16:05 No, there is no type checking, not even ByRef/ByVal checking. If you pass a value to a C parameter that requires an address, you'll blow up. In your specific example of a VBA Long passed to a C++ enum, you're probably alright (32-bit), but that is the exception to the rule, since under the hood the enum is just a 32-bit integer. DLL functions referenced via a Declare are completely outisde and independent of VBA's internal type conversions, error hanldling, and other hand-holding. Such functions are very unforgiiving. Screw it up and Excel will crash. Note, also, that in order to use a DLL function written in C++ from VBA, that function must have been compiled with the __stdcall directive. Cordially, Chip Pearson Microsoft Most Valuable Professional, Excel, 1998 - 2010 Pearson Software Consulting, LLC www.cpearson.com On Thu, 25 Feb 2010 11:50:43 -0800 (PST), l h <lhsofteng(a)gmail.com> wrote: >I'm new to VB/VBA and calling functions in external DLLs from VB/VBA. > >If I declare a variable in VBA, assign a value and then call a C++ >function in a DLL, is any type checking down between VBA and the C++ >function? So if I declare a Long identifier in VBA and then call a >function that expects an enum type in C++, will the call be flagged >for type mismatch? > >Thanks. > >Les
From: l h on 25 Feb 2010 16:26 On Feb 25, 1:05 pm, Chip Pearson <c...(a)cpearson.com> wrote: > No, there is no type checking, not even ByRef/ByVal checking. If you > pass a value to a C parameter that requires an address, you'll blow > up. > > In your specific example of a VBA Long passed to a C++ enum, you're > probably alright (32-bit), but that is the exception to the rule, > since under the hood the enum is just a 32-bit integer. DLL functions > referenced via a Declare are completely outisde and independent of > VBA's internal type conversions, error hanldling, and other > hand-holding. Such functions are very unforgiiving. Screw it up and > Excel will crash. > > Note, also, that in order to use a DLL function written in C++ from > VBA, that function must have been compiled with the __stdcall > directive. > > Cordially, > Chip Pearson > Microsoft Most Valuable Professional, > Excel, 1998 - 2010 > Pearson Software Consulting, LLCwww.cpearson.com > > On Thu, 25 Feb 2010 11:50:43 -0800 (PST), l h <lhsoft...(a)gmail.com> > wrote: > > >I'm new to VB/VBA and calling functions in external DLLs from VB/VBA. > > >If I declare a variable in VBA, assign a value and then call a C++ > >function in a DLL, is any type checking down between VBA and the C++ > >function? So if I declare a Long identifier in VBA and then call a > >function that expects an enum type in C++, will the call be flagged > >for type mismatch? > > >Thanks. > > >Les Thanks for your help Chip. Les
|
Pages: 1 Prev: list box controls - text property Next: Enter data on one sheet and copy to others |