Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello all,
Trying to call a C++ function from VBA. Function is declared as following in C++: func(char[],int[],int) The function reads the char*, does some manipulations on the data within it, and writes the results to the int*. There are two things I see as problems: 1) the int values in C++ are greater than the max value permitted in VBA 2) not sure how to pass the parameters to the dll from VBA I have been trying some combination of the following: func(ByRef string, ByRef int(1), ByVal int) i.e. sending down the address of the string, the address of the first element of the integer array and the value of an integer which corresponds to the number of iterations that are required for some processing done in the C++ code. Can anyone suggest how to address the two problems above? As it stands now, the code completely shuts down Excel without even a warning. Some illegal memory addressing I guess but not sure how to get around it. Thanks in advance. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
use long instead of integer in vba
long is signed 32 bit integer thekind78 wrote: Hello all, Trying to call a C++ function from VBA. Function is declared as following in C++: func(char[],int[],int) The function reads the char*, does some manipulations on the data within it, and writes the results to the int*. There are two things I see as problems: 1) the int values in C++ are greater than the max value permitted in VBA 2) not sure how to pass the parameters to the dll from VBA I have been trying some combination of the following: func(ByRef string, ByRef int(1), ByVal int) i.e. sending down the address of the string, the address of the first element of the integer array and the value of an integer which corresponds to the number of iterations that are required for some processing done in the C++ code. Can anyone suggest how to address the two problems above? As it stands now, the code completely shuts down Excel without even a warning. Some illegal memory addressing I guess but not sure how to get around it. Thanks in advance. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
One point to add
You should use ByVal for the first and second parameter The following link is quite useful http://support.microsoft.com/?scid=k...06553&x=16&y=9 Equiangular wrote: use long instead of integer in vba long is signed 32 bit integer thekind78 wrote: Hello all, Trying to call a C++ function from VBA. Function is declared as following in C++: func(char[],int[],int) The function reads the char*, does some manipulations on the data within it, and writes the results to the int*. There are two things I see as problems: 1) the int values in C++ are greater than the max value permitted in VBA 2) not sure how to pass the parameters to the dll from VBA I have been trying some combination of the following: func(ByRef string, ByRef int(1), ByVal int) i.e. sending down the address of the string, the address of the first element of the integer array and the value of an integer which corresponds to the number of iterations that are required for some processing done in the C++ code. Can anyone suggest how to address the two problems above? As it stands now, the code completely shuts down Excel without even a warning. Some illegal memory addressing I guess but not sure how to get around it. Thanks in advance. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Aug 23, 7:47 am, Equiangular wrote:
One point to add You should use ByVal for the first and second parameter The following link is quite usefulhttp://support.microsoft.com/?scid=kb%3Ben-us%3B106553&x=16&y=9 Equiangular wrote: use long instead of integer in vba long is signed 32 bit integer thekind78 wrote: Hello all, Trying to call a C++ function from VBA. Function is declared as following in C++: func(char[],int[],int) The function reads the char*, does some manipulations on the data within it, and writes the results to the int*. There are two things I see as problems: 1) the int values in C++ are greater than the max value permitted in VBA 2) not sure how to pass the parameters to the dll from VBA I have been trying some combination of the following: func(ByRef string, ByRef int(1), ByVal int) i.e. sending down the address of the string, the address of the first element of the integer array and the value of an integer which corresponds to the number of iterations that are required for some processing done in the C++ code. Can anyone suggest how to address the two problems above? As it stands now, the code completely shuts down Excel without even a warning. Some illegal memory addressing I guess but not sure how to get around it. Thanks in advance.- Hide quoted text - - Show quoted text - Equiangular, Thanks for your help. I'm still getting a Segmentation fault of sorts as Excel just shuts down. Is it necessary to register the dll before using it? Thank you. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Aug 23, 8:17 am, thekind78 wrote:
On Aug 23, 7:47 am, Equiangular wrote: One point to add You should use ByVal for the first and second parameter The following link is quite usefulhttp://support.microsoft.com/?scid=kb%3Ben-us%3B106553&x=16&y=9 Equiangular wrote: use long instead of integer in vba long is signed 32 bit integer thekind78 wrote: Hello all, Trying to call a C++ function from VBA. Function is declared as following in C++: func(char[],int[],int) The function reads the char*, does some manipulations on the data within it, and writes the results to the int*. There are two things I see as problems: 1) the int values in C++ are greater than the max value permitted in VBA 2) not sure how to pass the parameters to the dll from VBA I have been trying some combination of the following: func(ByRef string, ByRef int(1), ByVal int) i.e. sending down the address of the string, the address of the first element of the integer array and the value of an integer which corresponds to the number of iterations that are required for some processing done in the C++ code. Can anyone suggest how to address the two problems above? As it stands now, the code completely shuts down Excel without even a warning. Some illegal memory addressing I guess but not sure how to get around it. Thanks in advance.- Hide quoted text - - Show quoted text - Equiangular, Thanks for your help. I'm still getting a Segmentation fault of sorts as Excel just shuts down. Is it necessary to register the dll before using it? Thank you.- Hide quoted text - - Show quoted text - Also, Is it necessary for the DLL to include a LibMain function? It contains a DllEntryPoint function. Thanks for your help. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
I'm sorry that I'm not familiar with c++ DLL. For "traditional" DLL (I mean not activeX DLL), there is no need to register. Just call in a similar way like windows API. Some correction to make, the second parameter should be byref as this is an array. thekind78 wrote: On Aug 23, 8:17 am, thekind78 wrote: On Aug 23, 7:47 am, Equiangular wrote: One point to add You should use ByVal for the first and second parameter The following link is quite usefulhttp://support.microsoft.com/?scid=kb%3Ben-us%3B106553&x=16&y=9 Equiangular wrote: use long instead of integer in vba long is signed 32 bit integer thekind78 wrote: Hello all, Trying to call a C++ function from VBA. Function is declared as following in C++: func(char[],int[],int) The function reads the char*, does some manipulations on the data within it, and writes the results to the int*. There are two things I see as problems: 1) the int values in C++ are greater than the max value permitted in VBA 2) not sure how to pass the parameters to the dll from VBA I have been trying some combination of the following: func(ByRef string, ByRef int(1), ByVal int) i.e. sending down the address of the string, the address of the first element of the integer array and the value of an integer which corresponds to the number of iterations that are required for some processing done in the C++ code. Can anyone suggest how to address the two problems above? As it stands now, the code completely shuts down Excel without even a warning. Some illegal memory addressing I guess but not sure how to get around it. Thanks in advance.- Hide quoted text - - Show quoted text - Equiangular, Thanks for your help. I'm still getting a Segmentation fault of sorts as Excel just shuts down. Is it necessary to register the dll before using it? Thank you.- Hide quoted text - - Show quoted text - Also, Is it necessary for the DLL to include a LibMain function? It contains a DllEntryPoint function. Thanks for your help. |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The following URL gives a step by step example
http://www.che.utexas.edu/cache/news...001_useofc.pdf Hope it's useful to you thekind78 wrote: On Aug 23, 8:17 am, thekind78 wrote: On Aug 23, 7:47 am, Equiangular wrote: One point to add You should use ByVal for the first and second parameter The following link is quite usefulhttp://support.microsoft.com/?scid=kb%3Ben-us%3B106553&x=16&y=9 Equiangular wrote: use long instead of integer in vba long is signed 32 bit integer thekind78 wrote: Hello all, Trying to call a C++ function from VBA. Function is declared as following in C++: func(char[],int[],int) The function reads the char*, does some manipulations on the data within it, and writes the results to the int*. There are two things I see as problems: 1) the int values in C++ are greater than the max value permitted in VBA 2) not sure how to pass the parameters to the dll from VBA I have been trying some combination of the following: func(ByRef string, ByRef int(1), ByVal int) i.e. sending down the address of the string, the address of the first element of the integer array and the value of an integer which corresponds to the number of iterations that are required for some processing done in the C++ code. Can anyone suggest how to address the two problems above? As it stands now, the code completely shuts down Excel without even a warning. Some illegal memory addressing I guess but not sure how to get around it. Thanks in advance.- Hide quoted text - - Show quoted text - Equiangular, Thanks for your help. I'm still getting a Segmentation fault of sorts as Excel just shuts down. Is it necessary to register the dll before using it? Thank you.- Hide quoted text - - Show quoted text - Also, Is it necessary for the DLL to include a LibMain function? It contains a DllEntryPoint function. Thanks for your help. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|