Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

GPIB Issue

I am working on some legacy software (VB6) on a Windows 7 machine. I was adding some code totally unrelated to my GPIB issue. After I updated my code, I ran it in the VB6 IDE and had NO issues whatsoever. This includes the area in which GPIB is utilized. However, once I compiled it, it faults out with a "CIEEE: No GpibCard lGpib0 = -1". This is code that was implemented by a previous engineer in the past due to some issue he was having with the executable (he is no longer around for me to inquire what the issue was). 

 

The call that is creating the check for the "-1" is: lGpib0 = ibfind32(ByVal "GPIB0").

 

Which is derived from: Declare Function ibfind32 Lib "Gpib-32.dll" Alias "ibfindA" (sstr As Any) As Long

 

When I trap lGpib0 via a VB6 label and run it in the VB6 IDE, I get a "31000" instead of the "-1" and the code runs fine.

 

I've tried driver updates, commenting out code, faking the results all with the same results. When I run the tracer, it says that GPIB0 has the incorrect address. Yet nothing has been changed by an individual and I can only assume it was a corruption of some sort. I can find no way via MAX to check or change the address of GPIB0 to ensure it is correct. And why would it work OK in the VB6 IDE and not as an executable???

 

I appreciate any and all assistance or recommendations. I am about out of any and all ideas on how to correct this issue and I have to get this test stand back on-line ASAP.

 

Thanks

0 Kudos
Message 1 of 2
(2,748 Views)

How old is your VB6? Is it possible that it uses Widechar (Unicode) strings?

ibfindA would mean that it should use ASCII strings. And the function should definitely be declared as such. "sstr As Any, tells VB that it should pass whatever it finds as variable type and that would be a problem here.

 

You should probably try to use ibfindW instead or declare your ibfindA as follows:

 

Declare Function ibfind32 Lib "Gpib-32.dll" Alias "ibfindA" (ByVal sstr As String) As Long

 

String in VB6 is really a BSTR (16-bit Unicode string) but for a DLL function declaration when used together with the ByVal keyword, VB6 will "assume" that it is meant to be a C string pointer and will do the according conversions on the fly.

 

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 2
(793 Views)