Is anyone up to a challenge?

I have some problems linking to a C++ DLL with a VB program.

The program has this error:

Run-time error '13'
Type mismatch

It crashes at a line of code that is supposed to be calling a funciton in the C++ DLL.
The line of code is this:

ErrorStatus& = atxml_ValidateRequirements(XmlBuf, "PawsAllocation.xml", Response, 4096)

Now, let me tell you what everything is defined as:

Global ErrorStatus As Long
Global XmlBuf As String * 4096
Dim Response As String
Declare Function atxml_ValidateRequirements Lib "AtXmlApi_Dbg.dll" (ByVal resourceName$, ByVal IDQuery%, ByVal resetDevice%, instrumentHandle&) As Long

And in the C++ program:

extern "C" ATXML_FNC int atxml_ValidateRequirements(ATXML_ATML_Snippet* TestRequirements, ATXML_XML_Filename* Allocation, ATXML_XML_String* Availability, int BufferSize);

Recommended Answers

All 4 Replies

Is anyone up to a challenge?

I have some problems linking to a C++ DLL with a VB program.

The program has this error:

Run-time error '13'
Type mismatch

It crashes at a line of code that is supposed to be calling a funciton in the C++ DLL.
The line of code is this:

ErrorStatus& = atxml_ValidateRequirements(XmlBuf, "PawsAllocation.xml", Response, 4096)

Now, let me tell you what everything is defined as:

Global ErrorStatus As Long
Global XmlBuf As String * 4096
Dim Response As String
Declare Function atxml_ValidateRequirements Lib "AtXmlApi_Dbg.dll" (ByVal resourceName$, ByVal IDQuery%, ByVal resetDevice%, instrumentHandle&) As Long

And in the C++ program:

extern "C" ATXML_FNC int atxml_ValidateRequirements(ATXML_ATML_Snippet* TestRequirements, ATXML_XML_Filename* Allocation, ATXML_XML_String* Availability, int BufferSize);

how do you multiply a string?

shouldn't you be using integers?

Hi complete,

Firt of all - Kegtapper, "String * 4096" is the correct way to declare a fixed length string.

Now for the problem, looking at the declaration of atxml_ValidateRequirements the type mismatch is in the second argument - it should be an integer, the percent sign is the type declaration character of the integer.

Here are the type declaration characters for VB:
@ Currency
# Double
% Integer
& Long
! Single
$ String


Hope this helps

Yomet

I wasn't trying to be smart, I just do things differently.
Ok Then perhaps the Declare statement is incorrect:

don't declare the inner 2 parameters (either of them) as Integer, they should be String variables. The last one should be ok, (I think)

Declare Function atxml_ValidateRequirements Lib "AtXmlApi_Dbg.dll" (ByVal XmlBuf As String, ByVal "PawsAllocation.xml" As String, ByVal Response As String, 4096) As Long

i see several issues
but lets address code simplicity and compiler blindness first.
you declare
Global ErrorStatus As Long
then you treat the compiler with a redefinition by using
ErrorStatus&
a specious compiler could interpret that as two different variables

the type mismatch is occurring however
because args 2 and 3 are strings in the call
being shoved at integers in the declare
tisk...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.