From: tnomad@digital.net (The Nomad)
Subject: Re:[delphi] Calling a DLL with errors
Date: Wed, 14 Jun 1995 08:34:20 -0400

I missed this thread the first time around.  Sorry.  I am not a VB expert -
as a matter of fact, I have never used the language.  However, I recently
needed to interface to a VBX from Delphi, and experienced some mild
annoyance with how it all works.  But, the following summarizes my success:

Given: The function I am interfacing to has the following declaration:

        Declare Function SpreadColNumberToLetter Lib "Spread20.VBX" 
                (ByVal cn as Long) as String

That translates to the delphi external reference shown below:

	SpreadColNumberToLetter: function(const lHeaderNumber : LongInt): TBasicString;

Ahh you say - What is TBasicString?  It is declared in the VBXCTRL unit as
follows:

        TBasicString = ^Word;

To encapsulate the functionality, I wrote the following function:

        function TC_SpreadSheet.ColNumberToLetter(const headerNum: LongInt):
String;
        var
            str: TBasicString;
        begin
            str := SpreadColNumberToLetter(headerNum);
            result := BStrPas(str);     { BStrPas defined in VBXCTRL }
        end;

The companion function to BStrPas is BStrPCopy.  BStrPCopy receives a Pascal
string, and converts it to a TBasicString.  The two function prototypes are
shown below (note - these were lifted from the DELPHI\DOC\VBXCTRL.INT file):

function BStrPas(BasicStr: TBasicString): string;
function BStrPCopy(const Str: string): TBasicString;


I Hope this helps...
************************************
*           The Nomad              *
*        tnomad@digital.net        *
************************************
