LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Passing arguments from VBA to DLL

Hi!

I just took the first few steps in writing a little DLL that should
be called from Excel/VBA, and I stumbled upon some wierd behaviour.

The function in my DLL is declared as

int __stdcall foo( const char *t );

and is used in VBA via

Declare Function foo Lib "C:\foo\foo.dll" (ByVal t As String) As Long

I noticed that foo didn't work internally as I expected and added
writing *t to a file on each call of foo as a debugging measure.
According to this output, only the first character of String t seems
to be passed to foo when called directly from Excel (putting
=foo("xyz") in a cell).

However, if I wrap foo with

Function call_foo(t As String) As Long
call_foo = foo(t)
End Function

and use the formula =call_foo("xyz"), everything works ok.

Any ideas?

Regards,
Matthias

PS. Any other hints to "VBA calls DLL" documentation are appreciated

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing Arguments in Excell UB Excel Worksheet Functions 3 February 13th 07 04:08 PM
Passing arguments to userforms Steve Excel Programming 2 June 13th 06 05:31 PM
Passing arguments to VB Function Tom Excel Programming 1 March 29th 06 01:19 AM
Passing Arguments Grant Reid Excel Programming 8 May 24th 04 01:39 PM
Passing arguments to a sub routine... Jeff Harbin[_2_] Excel Programming 2 January 29th 04 03:25 AM


All times are GMT +1. The time now is 08:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"