Visual Basic 2005 サンプルプログラム
設定と問い合わせのサンプルプログラム(USB)
'VISAのResourceManagerオブジェクトを作成
Dim rm As New Ivi.Visa.Interop.ResourceManager
Dim accessMode As Ivi.Visa.Interop.AccessMode = Ivi.Visa.Interop.AccessMode.NO_LOCK
'ファンクションジェネレータの製造番号
Dim serial As String = "0123456"
Dim timeOut As Integer = 0
Dim optionString As String = ""
'デバイスと接続(USB)
'WF1973の場合 "USB0::0x0D4A::0x000D::" としてください
'WF1974の場合 "USB0::0x0D4A::0x000E::" としてください
Dim msg As Ivi.Visa.Interop.IMessage = CType( _
rm.Open("USB0::0x0D4A::0x000D::" & serial & "::INSTR", _
accessMode, _
timeOut, _
optionString), _
Ivi.Visa.Interop.IMessage)
'周波数を5.0kHzに設定し、その値を問い合わせる
msg.WriteString(":FREQ 5000;:FREQ?" & vbLf)
Console.WriteLine(msg.ReadString(256))
'デバイスを閉じる
msg.Close()
設定と問い合わせのサンプルプログラム(GPIB)
'VISAのResourceManagerオブジェクトを作成
Dim rm As New Ivi.Visa.Interop.ResourceManager
Dim accessMode As Ivi.Visa.Interop.AccessMode = Ivi.Visa.Interop..AccessMode.NO_LOCK
Dim timeOut As Integer = 0
Dim optionString As String = ""
'デバイスと接続(GPIB address:2)
Dim msg As Ivi.Visa.Interop.IMessage = CType( _
rm.Open("GPIB0::2::INSTR", _
accessMode, _
timeOut, _
optionString), _
Ivi.Visa.Interop.IMessage)
'オフセット 0.0V、振幅 20.0Vp-p、出力 オンを設定し、振幅の値を問い合わせる
msg.WriteString(":SOUR1:VOLT:OFFS 0V;:SOUR1:VOLT 20VPP;OUTP1 1;:SOUR1:VOLT?" & vbLf)
Console.WriteLine(msg.ReadString(256))
'デバイスを閉じる
msg.Close()