VBA(Office 2003) Sample Program
Sample program of setting and queries (USB)
'Create VISA ResourceManager object
Dim rm As New VisaComLib.ResourceManager
Dim accessMode As VisaComLib.accessMode
Dim serial As String
Dim timeOut As Integer
Dim optionString As String
Dim msg As VisaComLib.IMessage
accessMode = VisaComLib.accessMode.NO_LOCK
'Serial number of the fmultifunction generator
serial = "0123456"
timeOut = 0
optionString = ""
'Connect with the device(USB)
Set msg = rm.Open("USB0::0x0D4A::0x000F::" & serial & "::INSTR", _
accessMode, _
timeOut, _
optionString)
'Set the frequncy as 5.0 kHz, and ask the value
msg.WriteString(":FREQ 5000;:FREQ?" & vbLf)
Debug.Print msg.ReadString(256)
'Close the device
msg.Close
Sample program of setting and queries (GPIB)
'Create VISA ResourceManager object
Dim rm As New VisaComLib.ResourceManager
Dim accessMode As VisaComLib.accessMode
Dim timeOut As Integer
Dim optionString As String
Dim msg As VisaComLib.IMessage
accessMode = VisaComLib.accessMode.NO_LOCK
timeOut = 0
optionString = ""
'Connect with the device(GPIB address:2)
Set msg = rm.Open("GPIB0::2::INSTR", _
accessMode, _
timeOut, _
optionString)
'Set the Offset as 0.0V, Amplitude as 20.0Vp-p and Output as on,
'and ask the value
msg.WriteString(":SOUR1:VOLT:OFFS 0V;:SOUR1:VOLT 20VPP;OUTP1 1;:SOUR1:VOLT?" & vbLf)
Console.WriteLine(msg.ReadString(256))
'Close the device
msg.Close()