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 cmdDigOutput As System.Windows.Forms.Button
	Public WithEvents cmdDigInput As System.Windows.Forms.Button
	Public WithEvents cmdReadTotalizer As System.Windows.Forms.Button
	Public WithEvents cmdDCoutput As System.Windows.Forms.Button
	Public WithEvents txtIOaddress As System.Windows.Forms.TextBox
	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.cmdDigOutput = New System.Windows.Forms.Button
        Me.cmdDigInput = New System.Windows.Forms.Button
        Me.cmdReadTotalizer = New System.Windows.Forms.Button
        Me.cmdDCoutput = New System.Windows.Forms.Button
        Me.txtIOaddress = New System.Windows.Forms.TextBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.SuspendLayout()
        '
        'cmdDigOutput
        '
        Me.cmdDigOutput.BackColor = System.Drawing.SystemColors.Control
        Me.cmdDigOutput.Cursor = System.Windows.Forms.Cursors.Default
        Me.cmdDigOutput.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdDigOutput.ForeColor = System.Drawing.SystemColors.ControlText
        Me.cmdDigOutput.Location = New System.Drawing.Point(290, 75)
        Me.cmdDigOutput.Name = "cmdDigOutput"
        Me.cmdDigOutput.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdDigOutput.Size = New System.Drawing.Size(122, 34)
        Me.cmdDigOutput.TabIndex = 5
        Me.cmdDigOutput.Text = "Dig I/O Output"
        '
        'cmdDigInput
        '
        Me.cmdDigInput.BackColor = System.Drawing.SystemColors.Control
        Me.cmdDigInput.Cursor = System.Windows.Forms.Cursors.Default
        Me.cmdDigInput.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdDigInput.ForeColor = System.Drawing.SystemColors.ControlText
        Me.cmdDigInput.Location = New System.Drawing.Point(290, 117)
        Me.cmdDigInput.Name = "cmdDigInput"
        Me.cmdDigInput.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdDigInput.Size = New System.Drawing.Size(122, 34)
        Me.cmdDigInput.TabIndex = 4
        Me.cmdDigInput.Text = "Dig I/O Input"
        '
        'cmdReadTotalizer
        '
        Me.cmdReadTotalizer.BackColor = System.Drawing.SystemColors.Control
        Me.cmdReadTotalizer.Cursor = System.Windows.Forms.Cursors.Default
        Me.cmdReadTotalizer.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdReadTotalizer.ForeColor = System.Drawing.SystemColors.ControlText
        Me.cmdReadTotalizer.Location = New System.Drawing.Point(290, 171)
        Me.cmdReadTotalizer.Name = "cmdReadTotalizer"
        Me.cmdReadTotalizer.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdReadTotalizer.Size = New System.Drawing.Size(122, 34)
        Me.cmdReadTotalizer.TabIndex = 3
        Me.cmdReadTotalizer.Text = "Read Totalizer"
        '
        '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(290, 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 = "DAC 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, 43)
        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"
        '
        '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, 21)
        Me.Label1.Name = "Label1"
        Me.Label1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label1.Size = New System.Drawing.Size(192, 24)
        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(443, 284)
        Me.Controls.Add(Me.cmdDigOutput)
        Me.Controls.Add(Me.cmdDigInput)
        Me.Controls.Add(Me.cmdReadTotalizer)
        Me.Controls.Add(Me.cmdDCoutput)
        Me.Controls.Add(Me.txtIOaddress)
        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
	''  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 Agilent34952A 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.
	'
	'
	' These programs demonstrate dc output, dig input/output, and use of the totalizer
	'
	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.Agilent34952A.Interop.IAgilent34952A
		
		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("Agilent34952A")
		
		' Set the DAC to 3 volts output at slot 1, channel 6
		dac.dac.Voltage("1006") = 3#
		
		'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 cmdDigInput_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdDigInput.Click
		' Reads the Digital IO at Slot 1
		Dim msg As String ' the error message
        Dim digIO As Agilent.Agilent34952A.Interop.IAgilent34952A
		
		Dim standardInitOptions As String
		Dim driverSetupOptions As String
		Dim myReading As Byte
		
		On Error GoTo ErrorHandler
		''''''''''''''''''''''''''''''''''''''''''''''''''
		' Setup IVI-defined initialization options
		standardInitOptions = "Cache=true, InterchangeCheck=false, QueryInstrStatus=false, RangeCheck=true, RecordCoercions=false, Simulate=false"
		
		' Setup driver-specific initialization options
		driverSetupOptions = "DriverSetup= Model=34980A, Trace=false"
		
        '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 34952 Personality:
		digIO = host.Personality.Select("Agilent34952A")
		
		' Read value of digIO channel 1
		myReading = digIO.Digital.ReadByte("1001")
		
		MsgBox("Digital IO returned: " & vbCrLf & myReading)
		
		'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 cmdDigOutput_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdDigOutput.Click
		' Sets the Digital IO at Slot 1 to a value of 9
		Dim msg As String ' the error message
        Dim digIO As Agilent.Agilent34952A.Interop.IAgilent34952A
		
		Dim standardInitOptions As String
		Dim driverSetupOptions As String
		Dim myReading As Byte
		
		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 34952 Personality:
		digIO = host.Personality.Select("Agilent34952A")
		
		'Send the value of 9 to the digital IO channel 1
		digIO.Digital.WriteByte("1001", 9)
		
		'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 cmdReadTotalizer_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdReadTotalizer.Click
		' Reads channel 1 of the Digital IO at Slot 1
		Dim msg As String ' the error message
        Dim digIO As Agilent.Agilent34952A.Interop.IAgilent34952A
		
		Dim standardInitOptions As String
		Dim driverSetupOptions As String
		Dim myReading As Double
		
		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 34952 Personality:
		digIO = host.Personality.Select("Agilent34952A")
		
		'Read the value on digital IO channel 1
		myReading = digIO.Totalize.ReadData("1005")
		
		MsgBox("Totalizer returned: " & vbCrLf & myReading)
		
		'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