Manipulating the Pointer Example (VB)

NI-VISA

Manipulating the Pointer 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
Dim addr
Dim mSpace
Dim Value
As ViStatus
As ViSession
As ViSession
As ViAddr
As Integer
As Integer
Rem Open Default Resource Manager
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 Address 16
Rem NOTE: For simplicity, we will not show error checking
stat = viOpen(dfltRM, "VXI0::16::INSTR", VI_NULL, VI_NULL, sesn)

mSpace = VI_A16_SPACE

stat = viMapAddress(sesn, mSpace, 0, &H40, VI_FALSE, VI_NULL, addr)

viPeek16 sesn, addr, Value
Rem Access a different register by manipulating the pointer.
viPeek16 sesn, addr + 2, Value

stat = viUnmapAddress(sesn)

Rem Close down the system

stat = viClose(sesn)
stat = viClose(dfltRM)

End Sub