Opening a Session Example (VB)

NI-VISA

Opening a Session Example (Visual Basic)

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
As ViStatus
As ViSession
As ViSession
Rem Open Default RM
stat = viOpenDefaultRM(dfltRM)
If (stat < VI_SUCCESS) Then

Rem Error initializing VISA...exiting
Exit Sub

End If

Rem Access other resources
stat = viOpen(dfltRM, "GPIB::1::INSTR", VI_NULL, VI_NULL, sesn)

Rem Use device and eventually close it.
stat = viClose (sesn)
stat = viClose (dfltRM)

End Sub