Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Using viGetAttribute in VB

I'm trying to use the VISA function viGetAttribute in a VB application. The
attribute is VI_ATTR_INTF_INST_NAME. The data type in VB is a string. I get
a "can't read memory" error when I try to use function. Do I need to declare
the string a defined length?
Thank you
Gary
0 Kudos
Message 1 of 2
(4,653 Views)
The main thing is that you must allocate the memory for the string, viGetAttribute does not handle memory allocation.

I personally just fill the string with spaces before passing it to the function, then use the RTrim() function to remove the extra spaces like so:
Dim buf as string
buf = String(255, " ")
viGetAttribute(vi, VI_ATTR_RSRC_NAME, buf)
RTrim(buf)


just make sure you fill the string with enough spaces to hold the return value.
Message 2 of 2
(4,653 Views)