好,我这就把代码附上。 Option Explicit' """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""' ' Copyright (c) Agilent Technologies Inc. 1999. All Rights Reserved. ' ' ' ' Agilent Technologies provides programming samples for illustration ' ' purposes only. This sample program assumes that you are familiar ' ' with the programming language being demonstrated and the tools used ' ' to create and debug procedures. Agilent support engineers can help answer ' ' questions relating to the functionality of the software components ' ' provided by Agilent, but they will not modify these samples to provide added ' ' functionality or construct procedures to meet your specific needs. ' ' ' ' You have a royalty-free right to use, modify, reproduce, and distribute ' ' this sample program (and/or any modified version) in any way you find ' ' useful, provided that you agree that Agilent has no warranty, obligations, ' ' or liability for any sample programs. ' ' ' ' """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""'Dim nextTime As Variant Dim continue As Boolean Dim Scope As VisaComLib.FormattedIO488 Dim i As Integer Dim T As IntegerSub cmdStart_Click() ' set continue true to set the monitor continue = True ' start the readings update
End SubSub cmdstop_click() Dim AMPTarget As Variant Dim i As Integer For i = 0 To 178 AMPTarget = Cells(10 + i, 1) Cells(10 + i, 2) = ""Next End SubSub update() ' Using the Agt3494A control on this sheet, get the frequency ' and place in cell 'A1' ' set the timer to take the next reading Dim Freq As Long Dim reply As String Dim AMP As Variant Dim AMP2 As String Dim AMPTarget As Variant Dim FeqUp As Variant Dim FeqDown As Variant
On Error GoTo MeasureError If continue Then ' take the reading
MeasureError: continue = False MsgBox "Error making measurement." & vbCrLf & _ "Check IO settings, and make sure you have a valid waveform for this measurement." End SubSub SetIO(ByRef ioAddress As String) ' set the I/O address to the text box in case the ' user changed it. ' bring up the input dialog and save any changes to the ' text box Dim mgr As AgilentRMLib.SRMCls On Error GoTo ioError ioAddress = InputBox("Enter the IO address of the Scope", "Set IO address", ioAddress) If Len(ioAddress) > 5 Then Set mgr = New AgilentRMLib.SRMCls Set Scope = New VisaComLib.FormattedIO488 Set Scope.IO = mgr.Open(ioAddress) End If
Exit Sub
ioError: MsgBox "Set IO error:" & vbCrLf & Err.DescriptionEnd SubPrivate Sub CommandButton2_Click() SetIO Cells(5, 3) End Sub'------------------延时程序--------- Sub delay(T As Single) Dim T1 As Single T1 = Timer Do DoEvents Loop While Timer - T1 < T End Sub
EXCEL界面上主要就三个按钮。
Dim Scope As VisaComLib.FormattedIO488 ' Using the Agt3494A control on this sheet, get the frequency ' and place in cell 'A1' ' set the timer to take the next reading 需要使用控件,看或搜相关控件的使用手册。
Option Explicit' """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""'
' Copyright (c) Agilent Technologies Inc. 1999. All Rights Reserved. '
' '
' Agilent Technologies provides programming samples for illustration '
' purposes only. This sample program assumes that you are familiar '
' with the programming language being demonstrated and the tools used '
' to create and debug procedures. Agilent support engineers can help answer '
' questions relating to the functionality of the software components '
' provided by Agilent, but they will not modify these samples to provide added '
' functionality or construct procedures to meet your specific needs. '
' '
' You have a royalty-free right to use, modify, reproduce, and distribute '
' this sample program (and/or any modified version) in any way you find '
' useful, provided that you agree that Agilent has no warranty, obligations, '
' or liability for any sample programs. '
' '
' """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""'Dim nextTime As Variant
Dim continue As Boolean
Dim Scope As VisaComLib.FormattedIO488
Dim i As Integer
Dim T As IntegerSub cmdStart_Click() ' set continue true to set the monitor
continue = True
' start the readings
update
End SubSub cmdstop_click()
Dim AMPTarget As Variant
Dim i As Integer For i = 0 To 178
AMPTarget = Cells(10 + i, 1)
Cells(10 + i, 2) = ""Next
End SubSub update()
' Using the Agt3494A control on this sheet, get the frequency
' and place in cell 'A1'
' set the timer to take the next reading
Dim Freq As Long
Dim reply As String
Dim AMP As Variant
Dim AMP2 As String
Dim AMPTarget As Variant
Dim FeqUp As Variant
Dim FeqDown As Variant
On Error GoTo MeasureError
If continue Then ' take the reading
'----------------滤波器1测试--------------------
MsgBox "开始测试放大器"
'-----测试频点增益----
Scope.WriteString "CHAN1"
'Scope.WriteString "STAR 6GHZ"
'Scope.WriteString "STOP 18GHZ"
Scope.WriteString "AVEROOff"
'delay 1
Scope.WriteString "AVEROOn"
delay 8
Dim i As Integer
For i = 0 To 178
AMPTarget = 0.3 + i * 0.1
Scope.WriteString "MARK1" & Str$(AMPTarget) & "GHz"
Scope.WriteString "OUTPMARK"
AMP = Scope.ReadNumber
Cells(10 + i, 2) = AMP
Next
'delay 1
Scope.WriteString "AVEROOff"
delay 1
MsgBox "测试完毕"
End If
Exit Sub
MeasureError:
continue = False
MsgBox "Error making measurement." & vbCrLf & _
"Check IO settings, and make sure you have a valid waveform for this measurement."
End SubSub SetIO(ByRef ioAddress As String)
' set the I/O address to the text box in case the
' user changed it.
' bring up the input dialog and save any changes to the
' text box
Dim mgr As AgilentRMLib.SRMCls On Error GoTo ioError ioAddress = InputBox("Enter the IO address of the Scope", "Set IO address", ioAddress) If Len(ioAddress) > 5 Then
Set mgr = New AgilentRMLib.SRMCls
Set Scope = New VisaComLib.FormattedIO488
Set Scope.IO = mgr.Open(ioAddress)
End If
Exit Sub
ioError:
MsgBox "Set IO error:" & vbCrLf & Err.DescriptionEnd SubPrivate Sub CommandButton2_Click()
SetIO Cells(5, 3)
End Sub'------------------延时程序---------
Sub delay(T As Single)
Dim T1 As Single
T1 = Timer
Do
DoEvents
Loop While Timer - T1 < T
End Sub
' Using the Agt3494A control on this sheet, get the frequency
' and place in cell 'A1'
' set the timer to take the next reading
需要使用控件,看或搜相关控件的使用手册。