Option Strict Off
Option Explicit On
Friend Class Form1
	Inherits System.Windows.Forms.Form
#Region "Windows Form Designer generated code "
	Public Sub New()
		MyBase.New()
		If m_vb6FormDefInstance Is Nothing Then
			If m_InitializingDefInstance Then
				m_vb6FormDefInstance = Me
			Else
				Try 
					'For the start-up form, the first instance created is the default instance.
					If System.Reflection.Assembly.GetExecutingAssembly.EntryPoint.DeclaringType Is Me.GetType Then
						m_vb6FormDefInstance = Me
					End If
				Catch
				End Try
			End If
		End If
		'This call is required by the Windows Form Designer.
		InitializeComponent()
	End Sub
	'Form overrides dispose to clean up the component list.
	Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean)
		If Disposing Then
			If Not components Is Nothing Then
				components.Dispose()
			End If
		End If
		MyBase.Dispose(Disposing)
	End Sub
	'Required by the Windows Form Designer
	Private components As System.ComponentModel.IContainer
	Public ToolTip1 As System.Windows.Forms.ToolTip
	Public WithEvents cmdSineOutput As System.Windows.Forms.Button
	Public WithEvents cmdDCoutput As System.Windows.Forms.Button
	Public WithEvents txtIOaddress As System.Windows.Forms.TextBox
	Public WithEvents Label2 As System.Windows.Forms.Label
	Public WithEvents Label1 As System.Windows.Forms.Label
	'NOTE: The following procedure is required by the Windows Form Designer
	'It can be modified using the Windows Form Designer.
	'Do not modify it using the code editor.
	<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
        Me.cmdSineOutput = New System.Windows.Forms.Button
        Me.cmdDCoutput = New System.Windows.Forms.Button
        Me.txtIOaddress = New System.Windows.Forms.TextBox
        Me.Label2 = New System.Windows.Forms.Label
        Me.Label1 = New System.Windows.Forms.Label
        Me.SuspendLayout()
        '
        'cmdSineOutput
        '
        Me.cmdSineOutput.BackColor = System.Drawing.SystemColors.Control
        Me.cmdSineOutput.Cursor = System.Windows.Forms.Cursors.Default
        Me.cmdSineOutput.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdSineOutput.ForeColor = System.Drawing.SystemColors.ControlText
        Me.cmdSineOutput.Location = New System.Drawing.Point(250, 75)
        Me.cmdSineOutput.Name = "cmdSineOutput"
        Me.cmdSineOutput.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdSineOutput.Size = New System.Drawing.Size(122, 34)
        Me.cmdSineOutput.TabIndex = 3
        Me.cmdSineOutput.Text = "Sine Output"
        '
        'cmdDCoutput
        '
        Me.cmdDCoutput.BackColor = System.Drawing.SystemColors.Control
        Me.cmdDCoutput.Cursor = System.Windows.Forms.Cursors.Default
        Me.cmdDCoutput.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdDCoutput.ForeColor = System.Drawing.SystemColors.ControlText
        Me.cmdDCoutput.Location = New System.Drawing.Point(250, 21)
        Me.cmdDCoutput.Name = "cmdDCoutput"
        Me.cmdDCoutput.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdDCoutput.Size = New System.Drawing.Size(122, 34)
        Me.cmdDCoutput.TabIndex = 2
        Me.cmdDCoutput.Text = "dc Output"
        '
        'txtIOaddress
        '
        Me.txtIOaddress.AcceptsReturn = True
        Me.txtIOaddress.AutoSize = False
        Me.txtIOaddress.BackColor = System.Drawing.SystemColors.Window
        Me.txtIOaddress.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.txtIOaddress.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtIOaddress.ForeColor = System.Drawing.SystemColors.WindowText
        Me.txtIOaddress.Location = New System.Drawing.Point(20, 32)
        Me.txtIOaddress.MaxLength = 0
        Me.txtIOaddress.Name = "txtIOaddress"
        Me.txtIOaddress.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.txtIOaddress.Size = New System.Drawing.Size(192, 34)
        Me.txtIOaddress.TabIndex = 1
        Me.txtIOaddress.Text = "GPIB0::9::INSTR"
        '
        'Label2
        '
        Me.Label2.BackColor = System.Drawing.SystemColors.Control
        Me.Label2.Cursor = System.Windows.Forms.Cursors.Default
        Me.Label2.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label2.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Label2.Location = New System.Drawing.Point(0, 149)
        Me.Label2.Name = "Label2"
        Me.Label2.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label2.Size = New System.Drawing.Size(372, 120)
        Me.Label2.TabIndex = 4
        Me.Label2.Text = "This simple code example demonstrates how to output a 2 volt dc output or an inte" & _
        "rnally generated sine wave output. The code uses Slot 1 channel 1. You must have" & _
        " a 34951A in slot 1 of the 34980A mainframe."
        '
        'Label1
        '
        Me.Label1.BackColor = System.Drawing.SystemColors.Control
        Me.Label1.Cursor = System.Windows.Forms.Cursors.Default
        Me.Label1.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label1.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Label1.Location = New System.Drawing.Point(20, 11)
        Me.Label1.Name = "Label1"
        Me.Label1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label1.Size = New System.Drawing.Size(192, 23)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "I/O address:"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 16)
        Me.BackColor = System.Drawing.SystemColors.Control
        Me.ClientSize = New System.Drawing.Size(390, 284)
        Me.Controls.Add(Me.cmdSineOutput)
        Me.Controls.Add(Me.cmdDCoutput)
        Me.Controls.Add(Me.txtIOaddress)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Label1)
        Me.Cursor = System.Windows.Forms.Cursors.Default
        Me.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Location = New System.Drawing.Point(5, 29)
        Me.Name = "Form1"
        Me.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub
#End Region 
#Region "Upgrade Support "
	Private Shared m_vb6FormDefInstance As Form1
	Private Shared m_InitializingDefInstance As Boolean
	Public Shared Property DefInstance() As Form1
		Get
			If m_vb6FormDefInstance Is Nothing OrElse m_vb6FormDefInstance.IsDisposed Then
				m_InitializingDefInstance = True
				m_vb6FormDefInstance = New Form1()
				m_InitializingDefInstance = False
			End If
			DefInstance = m_vb6FormDefInstance
		End Get
		Set
			m_vb6FormDefInstance = Value
		End Set
	End Property
#End Region 
	
	'' """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    ''  © Agilent Technologies Inc. 2004, 2005, 2006
	''  All rights reserved.
	''
	'' You have a royalty-free right to use, modify, reproduce and distribute
	'' the Sample Application Files (and/or any modified version) in any way
	'' you find useful, provided that you agree that Agilent Technologies has no
	'' warranty, obligations or liability for any Sample Application Files.
	''
	'' Agilent Technologies provides programming examples for illustration 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 Technologies support engineers can help explain the
	'' functionality of Agilent Technologies software components and associated
	'' commands, but they will not modify these samples to provide added
	'' functionality or construct procedures to meet your specific needs.
	'' """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
	
	' This program uses the Agilent 34980A IVI-COM driver.
	' The IVI-COM driver is loaded as a reference from the Project/References menu
	' When loading the references, select:
	'           IVI Agilent34980A 1.0 Type Library
	'           IVI Agilent34951A 1.0 Type Library
	'
	' This program requires either NI Visa or
	' Visa from Agilent I/O library version M or later to be installed
	' on the computer.
	'
	' 34951A
	' This program demonstrates the use of the 34951A to create dc output, and a sine wave
	' from the internal waveforms
	
	Private Sub cmdDCoutput_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdDCoutput.Click
		' Set the DAC at Slot 1, Channel 1 to 3 volts dc output
		Dim msg As String ' the error message
        Dim dac As Agilent.Agilent34951A.Interop.IAgilent34951A
		
		Dim standardInitOptions As String
		Dim driverSetupOptions As String
		
		On Error GoTo ErrorHandler
		''''''''''''''''''''''''''''''''''''''''''''''''''
		' Setup IVI-defined initialization options
		standardInitOptions = "QueryInstrStatus=false, Simulate=false"
		
		' Setup driver-specific initialization options
		driverSetupOptions = "DriverSetup= Model=34980A"
		
		'Open a session to the mainframe
        Dim host As New Agilent.Agilent34980A.Interop.Agilent34980A
		
		' Send a reset when we open the instrument
        host.Initialize(txtIOaddress.Text, False, True, standardInitOptions & "," & driverSetupOptions)
		
		'Select the 34951 Personality:
		dac = host.Personality.Select("Agilent34951A")
		
		' turn off the output and waveform if it is on
		dac.Output.State("1001") = False
		
        'Output a 3.0 Volt level on channel 1 -- this closes the output relay as well
		dac.Source.ApplyLevel("1001", Agilent.Agilent34951A.Interop.Agilent34951AFunctionTypeEnum.Agilent34951AFunctionTypeVoltage, 3#)

        msg = "Outputting DC Level"
        MsgBox(msg)

		'Close the IO session
        host.Close()
		
ErrorHandler: 
		If Err.Number <> 0 Then
			msg = "Error # " & Str(Err.Number) & " was generated by " & Err.Source & Err.Description
			
			MsgBox(msg)
		End If
		
	End Sub
	
	Private Sub cmdSineOutput_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdSineOutput.Click
		' Sets the DAC at Slot 1, channel 1 for a sine wave, 200 Hz, 500points
		' and 2 volts output
		Const WF_Name As String = "EXAMPLETRACE"
		
		Dim msg As String ' the error message
        Dim dac As Agilent.Agilent34951A.Interop.IAgilent34951A
		Dim strTemp As String
		Dim standardInitOptions As String
		Dim driverSetupOptions As String
		
		On Error GoTo ErrorHandler
		''''''''''''''''''''''''''''''''''''''''''''''''''
		' Setup IVI-defined initialization options
		standardInitOptions = "QueryInstrStatus=false, Simulate=false"
		
		' Setup driver-specific initialization options
		driverSetupOptions = "DriverSetup= Model=34980A"
		
		'Open a session to the mainframe
        Dim host As New Agilent.Agilent34980A.Interop.Agilent34980A
		
		' Send a reset when we open the instrument
        host.Initialize(txtIOaddress.Text, False, True, standardInitOptions & "," & driverSetupOptions)
		
		'Select the 34951 Personality:
		dac = host.Personality.Select("Agilent34951A")
		
        'Create a sinusoid waveform trace 500 points in size.
		dac.Trace.CreateStandard(1, WF_Name, 500, Agilent.Agilent34951A.Interop.Agilent34951ATraceWaveformEnum.Agilent34951ATraceWaveformSinusoid)
		
		'Output the newly created trace as a voltage waveform with frequency of 200 Hz
		'and gain of 2.0
		dac.Source.ApplyTrace("1001", WF_Name, Agilent.Agilent34951A.Interop.Agilent34951AFunctionTypeEnum.Agilent34951AFunctionTypeVoltage, 2#, 0#, 200#)

        msg = "Outputting sine wave"
        MsgBox(msg)

		'Close the IO session
        host.Close()
		
ErrorHandler: 
		If Err.Number <> 0 Then
			msg = "Error # " & Str(Err.Number) & " was generated by " & Err.Source & Err.Description
			
			MsgBox(msg)
		End If
		
	End Sub
End Class