Specifications
ZVx Programming Examples
1043.0009.50 D.9 E-2
Programming example:
• Using the macro QueryMaxPeak a single sweep with subsequent query of the maximum peak is
performed. The result is entered in a Winword or Excel document.
Sub QueryMaxPeak()
Dim ibsta As Integer ’ Status variable
Dim iberr As Integer ’ Error variable
Dim ibcntl As Long ’ transferred characters
Dim ud As Integer ’ Unit Descriptor (handle)for instrument
Dim Response As String ’ Response string
’ Set up connection to measuring instrument
ud = RSDLLibfind("89.10.38.97", ibsta, iberr, ibcntl)
If (ud < 0) Then
Call MsgBox("Device with address 89.10.38.97 could" & _
"not be found", vbExclamation)
End
End If
’ Determine maximum peak in the range 1-2MHZ
Call RSDLLibwrt(ud, "*RST", ibsta, iberr, ibcntl)
Call RSDLLibwrt(ud, "INIT:CONT OFF", ibsta, iberr, ibcntl)
Call RSDLLibwrt(ud, "FREQ:START 1MHZ", ibsta, iberr, ibcntl)
Call RSDLLibwrt(ud, "FREQ:STOP 2MHZ", ibsta, iberr, ibcntl)
Call RSDLLibwrt(ud, "INIT:IMM;*WAI", ibsta, iberr, ibcntl)
Call RSDLLibwrt(ud, "CALC:MARK:MAX;Y?", ibsta, iberr, ibcntl)
Response = Space$(100)
Call RSDLLibrd(ud, Response, ibsta, iberr, ibcntl)
Response = RTrim(Response) ’ Cut off space
’ Insert value in current document (Winword)
Selection.InsertBefore (Response)
Selection.Collapse (wdCollapseEnd)
’ Terminate connection to measuring instrument
Call RSDLLibonl(ud, 0, ibsta, iberr, ibcntl)
End Sub
The entry of the peak value in the Winword document can be replaced as follows for Excel:
’ Insert value in current document (Excel)
ActiveCell.FormulaR1C1 = Response