Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

use gpib-32.dll with visual basic .net

Hello,

I want to use the GPI-32.DLL with visual basic .Net.
But I've somes problems :

When I Use the function ibrd32, i can't received the String read by the function
My function is declared as :

Declare Function ibrd32 Lib "Gpib-32.dll" Alias "ibrd" (ByVal ud As Integer, ByRef sstr As String, ByVal cnt As Integer) As Integer
When I receive a string Visual Studio say me that :

Une exception non gérée du type 'System.Runtime.InteropServices.InvalidOleVariantTypeException' s'est produite dans b_ieee.dll

Informations supplémentaires : Le variant OLE spécifié n'est pas valide.

How I will do for reveive correctly my string, What il the correctly declaration ?

Thanks For your help

PS : Sorry for my very bad Eng
lish I'm French
0 Kudos
Message 1 of 4
(4,430 Views)
Sorry I still haven't used .net so this is a guess. What happens if you add the word "Ansi" to your declaration:

Declare Ansi Function ibrd32 Lib "Gpib-32.dll" Alias "ibrd" (ByVal ud As Integer, ByRef sstr As String, ByVal cnt As Integer) As Integer
0 Kudos
Message 2 of 4
(4,430 Views)
The gpib-32.dll needs to be upgraded.
It doesn't have a good hand shaking with .Net string structure.
0 Kudos
Message 3 of 4
(4,430 Views)
You need to use a wrapper around the definitions and to define the string as a VB string. see example below

'Definition of buffer
Const ARRAYSIZE As Short = 1024 ' Size of read buffer
Dim ValueStr As New VB6.FixedLengthString(ARRAYSIZE)

'call to ilrd
ilrd(Dev, ValueStr.Value, ARRAYSIZE)

'defintion in VBIB-32.VB
' NI-488.2 DLL entry function declarations
Declare Function ibwrt32 Lib "Gpib-32.dll" Alias "ibwrt" (ByVal ud As Integer, ByRef sstr As String, ByVal cnt As Integer) As Integer
Declare Function ibrd32 Lib "Gpib-32.dll" Alias "ibrd" (ByVal ud As Integer, ByRef sstr As String, ByVal cnt As Integer) As Integer


I have downloaded a sam
ple simple GPIB project to the ni developers exchange.

if you forward me your email I will be happy to email you the zip.

Kevin@kotech.demon.co.uk
0 Kudos
Message 4 of 4
(4,430 Views)