ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

HELP! ilrd() problem in VB

I'm having trouble in VisualBasic with an HP DMM using the GPIB cmd :
ilrd(Dev%,ValueStr$,Len(ValueStr$)).
I'm pretty sure it's how I've dimensioned ValueStr$. What is the
proper way?
I've also seen the call used like:
ilrd(Dev%,ValueStr,Len(ValueStr)). No $ signs. Whats the difference?

my code uses:
Dim ValueStr As String
Dim Dev As integer
Also, what does the $ at the end of ValueStr mean, and the % on Dev?

0 Kudos
Message 1 of 6
(5,170 Views)
Check out the VB examples that ship with our driver.  These are usually located in C:\Program Files\National Instruments\NI-488.2\Languages\Visual Basic
 
Scott B.
GPIB Software
National Instruments
0 Kudos
Message 2 of 6
(5,162 Views)

In answer to the second question:

"Also, what does the $ at the end of ValueStr mean, and the % on Dev?"

The $ is the identifer for a string variable and % is the identifier for an integer variable.

Hope this helps clear it up.

 

0 Kudos
Message 3 of 6
(5,154 Views)
You must allocate enough buffer for the string variable before ILRD() or IBRD() call.  Just declaring a string variable with Dim ValueStr As String does not allocate any buffer and its default length is zero.
 
...
Dim ValueStr As String
ValueStr = SPACE(256)
status = ilrd(Dev,ValueStr,Len(ValueStr))
 
% specifies Integer type and $ specifies String type.  This style has been kept unchanged since GW-BASIC era. 
 
Dim X As Integer and Dim X% are the same for declaring an Integer, however Dim X declares Variant type.
 
0 Kudos
Message 4 of 6
(5,152 Views)
On Fri, 17 Mar 2006 11:41:48 -0600 (CST), Makoto <x@no.email> wrote:

>You must allocate enough buffer for the string variable before ILRD() or IBRD() call.&nbsp; Just declaring a string variable with Dim ValueStr As String does not allocate any buffer and its default length is zero.
>&nbsp;
>..
>Dim ValueStr As String
>ValueStr = SPACE(256)
>status = ilrd(Dev,ValueStr,Len(ValueStr))
>&nbsp;
>% specifies Integer type and $ specifies String type.&nbsp; This style has been kept unchanged since GW-BASIC era.&nbsp;
>&nbsp;
>Dim&nbsp;X As Integer and Dim X% are the same for declaring an Integer, however Dim&nbsp;X declares Variant type.
>&nbsp;

Thanks, this is what I needed:

Const ARRAYSIZE = 1024
Dim ValueStr As String * ARRAYSIZE

and I found out that Dim Count% is the same as Dim Count As Integer,
$, string...


0 Kudos
Message 5 of 6
(5,141 Views)
On Fri, 17 Mar 2006 09:41:44 -0600 (CST), ScottieB <x@no.email> wrote:

>Check out the VB examples that ship with our driver.&nbsp; These are usually located in C:\Program Files\National Instruments\NI-488.2\Languages\Visual Basic
>&nbsp;
>Scott B.GPIB Software
>National Instruments
Thanks, that just what I did and foun the problem!!!
0 Kudos
Message 6 of 6
(5,141 Views)