R3132 Series Spectrum Analyzer Operation Manual
4.2.10 Example Programs
4-54
Example VB-12: Measuring OBW and displaying it
Dim LENG1 As Integer, LENG2 As Integer
Dim OBW As String
Dim FC As String
Dim searchchar As String
Call ibclr(spa) ’ Perform a device clear.
Call ibwrt(spa, "CF 30MZ") ’ Send the command already set.
Call ibwrt(spa, "SP 1MZ")
Call ibwrt(spa, "MK 30MZ")
Call ibwrt(spa, "OBW ON")
Call ibwrt(spa, "TS")
Call ibwrt(spa, "OBW?") ’ Send the query command.
Rdbuff = Space(60) ’ Allocate the area to the read buffer.
Call ibrd(spa, Rdbuff) ’ Read the read buffer (the maximum number of bytes to be output
’ is determined by the buffer area size).
’ Formatting output character string
LENG1 = InStr(1, Rdbuff, Chr(44), 0) ’ Search for the first comma.
FC = Mid(Rdbuff, 1, LENG1 - 1) ’ Read the character prior to the comma.
DoEvents
LENG2 = InStr((LENG1 + 1), Rdbuff, Chr(13), 0) ’Determine the last data by searching for the delimiter.
OBW = Mid(Rdbuff, (LENG1 + 1), (LENG2 - LENG1-1))
’Read the data between the second comma and the delimiter.
RichTextBox1.Text = "OBW = " & OBW & vbCrLf & "Fc = " & FC & vbCrLf
’ Display the data on the screen.
An example display:
OBW = +9.810000000000E+05
FC = +3.000250000000E+07