Register-Based Communication Example (Visual Basic)

NI-VISA 15.0 Help

Edition Date: June 2015

Part Number: 370131S-01

»View Product Info
Note  The Visual Basic examples in the NI-VISA Help use the VISA data types where applicable. This feature is available only on Windows. To use this feature, select the VISA library (visa32.dll) as a reference from Visual Basic. This makes use of the type library embedded into the DLL.

Private Sub vbMain()

Dim stat
Dim dfltRM
Dim sesn
Dim deviceID
As ViStatus
As ViSession
As ViSession
As Integer
Rem Begin by initializing the system
stat = viOpenDefaultRM(dfltRM)
If (stat < VI_SUCCESS) Then

Rem Error initializing VISA...exiting
Exit Sub

End If

Rem Open communication with VXI Device at Logical Addr 16
Rem NOTE: For simplicity, we will not show error checking
stat = viOpen(dfltRM, "VXI0::16::INSTR", VI_NULL, VI_NULL, sesn)

Rem Read the Device ID and write to memory in A24 space
stat = viIn16(sesn, VI_A16_SPACE, 0, deviceID)
stat = viOut16(sesn, VI_A24_SPACE, 0, &H1234)

Rem Close down the system
stat = viClose(sesn)
stat = viClose(dfltRM)

End Sub


Not Helpful