
3-4
Agilent 4155C/4156C VXIplug&play Driver User’s Guide, Edition 4
Programming Examples for Visual Basic Users
Programming Basics
Table 3-1
Example Template Program Code for Visual Basic 6.0
Sub Main()
’1
’Starting the session *******************************************
Dim vi
As Long
Dim ret
As Long
Dim msg
As String
Dim err_msg
As String * 256
ret = hp4156b_init("GPIB::17::INSTR", VI_TRUE, VI_TRUE, vi)
’7
If ((vi = VI_NULL) Or (ret < VI_SUCCESS)) Then
msg = "Initialization failure." & Chr(10) & Chr(10) & "Status Code: " & ret
MsgBox msg, vbOKOnly, ""
If (vi <> VI_NULL) Then
ret = hp4156b_error_message(vi, ret, err_msg)
msg = "Error: " & ret & Chr(10) & Chr(10) & err_msg
MsgBox msg, vbOKOnly, ""
End If
End
End If
’17
ret = hp4156b_reset(vi)
’resets 4155/4156
’19
ret = hp4156b_timeOut(vi, 60000)
’sets time out to 60 sec
ret = hp4156b_errorQueryDetect(vi, VI_TRUE) ’enables error detection
msg = "Click OK to start measurement."
MsgBox msg, vbOKOnly, ""
’displays message box
perform_meas vi, ret
’calls perform_meas subprogram
25
’ret = hp4156b_cmd(vi, "aa")
’sends an invalid command
’check_err vi, ret
’checks check_err subprogram operation
Line
Description
1
Beginning of the Main subprogram.
3 to 6
Declares variables used in this program.
7
Establishes the software connection with the Agilent 4155/4156. The above example is
for the Agilent 4155/4156 on the GPIB address 17. Confirm the GPIB address of your
4155/4156, and set the address correctly instead of “17”.
8 to 17
Checks the status returned by the hp4156b_init function. If an error status is returned,
displays a message box to show the error message, and stops the program execution.
19 to 23
Resets the Agilent 4155/4156, sets the driver I/O time out to 60 seconds, and enables
the automatic instrument error checking. Also opens a message box to confirm start of
measurement.
25
Calls the perform_meas subprogram (line 38).
26 to 27
Should be deleted or commented out before executing the program. The lines are just
used to check the operation of the check_err subprogram.
Содержание 4155C
Страница 3: ......
Страница 13: ...1 Installation...
Страница 18: ...1 6 Agilent 4155C 4156C VXIplug play Driver User s Guide Edition 4 Installation Installing VXIplug play Driver...
Страница 19: ...2 Driver Function Reference...
Страница 89: ...3 Programming Examples for Visual Basic Users...
Страница 147: ...4 Programming Examples for Visual Basic NET Users...
Страница 183: ...5 Programming Examples for C Users...
Страница 225: ...6 Programming Examples for VEE Users...
Страница 271: ...7 Sample Application Programs Using VEE...