Agilent 4155C/4156C VXIplug&play Driver User’s Guide, Edition 4 3-51
Programming Examples for Visual Basic Users
Sampling Measurements
Sub save_data(vi As Long, ret As Long, nop As Long, index() As Long, bias As
Double, value() As Double, status() As Long, m() As Long) ’1
Dim i As Integer ’3
Dim data1 As Double
Dim data2 As Double
Dim r1 As Double
Dim r2 As Double
Dim val As String
val = "Index, I1 (mA), R1 (ohm), I2 (mA), R2 (ohm), Status"
For i = 0 To nop - 1
data1 = Round(value(2 * i) * 1000, 3)
data2 = Round(value(2 * i + 1) * 1000, 3)
r1 = Round(bias / value(2 * i), 2)
r2 = Round(bias / value(2 * i + 1), 2)
val = val & Chr(13) & Chr(10) & index(i) & "," & data1 & "," & r1
val = val & "," & data2 & "," & r2 & "," & status(i)
Next i
Dim fname As String ’data file name ’20
Dim fnum As Integer ’file number
fname = "C:\Agilent\data\data7.txt"
fnum = 1
Open fname For Output Access Write Lock Read Write As fnum
Print #fnum, val
Close fnum
Dim title As String ’28
Dim rbx As Integer
title = "Sampling Measurement Result"
val = val & Chr(10) & Chr(10) & "Data save completed."
val = val & Chr(10) & Chr(10) & "Do you want to perform measurement again?"
rbx = MsgBox(val, vbYesNo, title)
If rbx = vbYes Then
sampling_meas vi, ret, m()
End If
End Sub ’38
Line Description
1 Beginning of the save_data subprogram.
3 to 18 Declares variables, and creates data to be saved and displayed on a message box.
20 to 26 Saves measurement data into a file (C:\Agilent\data\data7.txt, CSV file).
28 to 36 Displays measurement data on a message box. If Yes is clicked on the message box,
performs the sampling_meas subprogram again. If No is clicked, returns to the
perform_meas subprogram.
38 End of the save_data subprogram.