Option Explicit 
’ Declarations for VISA.DLL 
’ Basic I/O Operations 
Private Declare Function viOpenDefaultRM Lib "VISA32.DLL" Alias "#141" (sesn As Long) As Long
Private Declare Function viOpen Lib "VISA32.DLL" Alias "#131" (ByVal sesn As Long, _ 
ByVal desc As String, ByVal mode As Long, ByVal TimeOut As Long, vi As Long) As Long Private 
Declare Function viClose Lib "VISA32.DLL" Alias "#132" (ByVal vi As Long) As Long Private Declare 
Function viRead Lib "VISA32.DLL" Alias "#256" (ByVal vi As Long, _ 
ByVal Buffer As String, ByVal Count As Long, retCount As Long) As Long 
Private Declare Function viWrite Lib "VISA32.DLL" Alias "#257" (ByVal vi As Long, _ 
ByVal Buffer As String, ByVal Count As Long, retCount As Long) As Long 
’ Error Codes 
Global Const VI_SUCCESS = 0  
’ Global Variables  
Global videfaultRM As Long   ’ Resource manager id for VISA GPIB  
Global vi As Long   ’ Stores the session for VISA  
Dim errorStatus As Long ’ VTL error code  
Global VISAaddr As String  
’""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" ’ This 
routine requires the file ’VISA32.DLL’ which typically resides in the 
’ c:\windows\system directory on your PC. This routine uses the VTL Library to send 
’ commands to the instrument. A description of these and additional VTL commands can be 
’ found in the Keysight VISA User’s Guide. 
’""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
Public Sub SendSCPI(SCPICmd As String) 
’ This routine sends a SCPI command string to the GPIB port. If the command is a 
’ query command (contains a question mark), you must read the response with ’getScpi’
Dim commandstr As String  ’ Command passed to instrument
  Dim actual As Long ’ Number of characters sent/returned
’Write the command to the instrument terminated by a line feed
commandstr = SCPICmd & Chr$(10)
errorStatus = viWrite(vi, ByVal commandstr, Len(commandstr), actual) 
End Sub