Option Strict Off
Option Explicit On 
Imports System.Runtime.InteropServices
Friend Class Parallel
	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 DelRet As System.Windows.Forms.Button
	Public WithEvents TextRet As System.Windows.Forms.TextBox
	Public WithEvents PollDel As System.Windows.Forms.Button
	Public WithEvents Exit_Renamed As System.Windows.Forms.Button
	Public WithEvents Initialize As System.Windows.Forms.Button
	Public WithEvents YrAdrBox2 As System.Windows.Forms.ComboBox
	Public WithEvents Label5 As System.Windows.Forms.Label
	Public WithEvents Frame3 As System.Windows.Forms.GroupBox
	Public WithEvents PollSts As System.Windows.Forms.TextBox
	Public WithEvents PollGo As System.Windows.Forms.TextBox
	Public WithEvents PollSet As System.Windows.Forms.TextBox
	Public WithEvents Label3 As System.Windows.Forms.Label
	Public WithEvents Label2 As System.Windows.Forms.Label
	Public WithEvents Label1 As System.Windows.Forms.Label
	Public WithEvents Frame2 As System.Windows.Forms.GroupBox
	Public WithEvents YrAdrBox1 As System.Windows.Forms.ComboBox
	Public WithEvents Label4 As System.Windows.Forms.Label
	Public WithEvents Frame1 As System.Windows.Forms.GroupBox
	Public WithEvents Polling As System.Windows.Forms.Button
	Public WithEvents Label6 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.DelRet = New System.Windows.Forms.Button()
        Me.TextRet = New System.Windows.Forms.TextBox()
        Me.PollDel = New System.Windows.Forms.Button()
        Me.Exit_Renamed = New System.Windows.Forms.Button()
        Me.Initialize = New System.Windows.Forms.Button()
        Me.Frame3 = New System.Windows.Forms.GroupBox()
        Me.YrAdrBox2 = New System.Windows.Forms.ComboBox()
        Me.Label5 = New System.Windows.Forms.Label()
        Me.Frame2 = New System.Windows.Forms.GroupBox()
        Me.PollSts = New System.Windows.Forms.TextBox()
        Me.PollGo = New System.Windows.Forms.TextBox()
        Me.PollSet = New System.Windows.Forms.TextBox()
        Me.Label3 = New System.Windows.Forms.Label()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.Frame1 = New System.Windows.Forms.GroupBox()
        Me.YrAdrBox1 = New System.Windows.Forms.ComboBox()
        Me.Label4 = New System.Windows.Forms.Label()
        Me.Polling = New System.Windows.Forms.Button()
        Me.Label6 = New System.Windows.Forms.Label()
        Me.Frame3.SuspendLayout()
        Me.Frame2.SuspendLayout()
        Me.Frame1.SuspendLayout()
        Me.SuspendLayout()
        '
        'DelRet
        '
        Me.DelRet.BackColor = System.Drawing.SystemColors.Control
        Me.DelRet.Cursor = System.Windows.Forms.Cursors.Default
        Me.DelRet.ForeColor = System.Drawing.SystemColors.ControlText
        Me.DelRet.Location = New System.Drawing.Point(456, 122)
        Me.DelRet.Name = "DelRet"
        Me.DelRet.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.DelRet.Size = New System.Drawing.Size(83, 33)
        Me.DelRet.TabIndex = 2
        Me.DelRet.Text = "D&elete"
        '
        'TextRet
        '
        Me.TextRet.AcceptsReturn = True
        Me.TextRet.AutoSize = False
        Me.TextRet.BackColor = System.Drawing.SystemColors.Window
        Me.TextRet.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.TextRet.ForeColor = System.Drawing.SystemColors.WindowText
        Me.TextRet.Location = New System.Drawing.Point(104, 176)
        Me.TextRet.MaxLength = 0
        Me.TextRet.Name = "TextRet"
        Me.TextRet.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.TextRet.Size = New System.Drawing.Size(433, 25)
        Me.TextRet.TabIndex = 7
        Me.TextRet.Text = ""
        '
        'PollDel
        '
        Me.PollDel.BackColor = System.Drawing.SystemColors.Control
        Me.PollDel.Cursor = System.Windows.Forms.Cursors.Default
        Me.PollDel.ForeColor = System.Drawing.SystemColors.ControlText
        Me.PollDel.Location = New System.Drawing.Point(360, 18)
        Me.PollDel.Name = "PollDel"
        Me.PollDel.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.PollDel.Size = New System.Drawing.Size(79, 27)
        Me.PollDel.TabIndex = 3
        Me.PollDel.Text = "&Delete"
        '
        'Exit_Renamed
        '
        Me.Exit_Renamed.BackColor = System.Drawing.SystemColors.Control
        Me.Exit_Renamed.Cursor = System.Windows.Forms.Cursors.Default
        Me.Exit_Renamed.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Exit_Renamed.Location = New System.Drawing.Point(456, 72)
        Me.Exit_Renamed.Name = "Exit_Renamed"
        Me.Exit_Renamed.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Exit_Renamed.Size = New System.Drawing.Size(83, 35)
        Me.Exit_Renamed.TabIndex = 1
        Me.Exit_Renamed.Text = "E&xit"
        '
        'Initialize
        '
        Me.Initialize.BackColor = System.Drawing.SystemColors.Control
        Me.Initialize.Cursor = System.Windows.Forms.Cursors.Default
        Me.Initialize.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Initialize.Location = New System.Drawing.Point(456, 20)
        Me.Initialize.Name = "Initialize"
        Me.Initialize.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Initialize.Size = New System.Drawing.Size(83, 35)
        Me.Initialize.TabIndex = 0
        Me.Initialize.Text = "&Initialize"
        '
        'Frame3
        '
        Me.Frame3.BackColor = System.Drawing.SystemColors.Control
        Me.Frame3.Controls.AddRange(New System.Windows.Forms.Control() {Me.YrAdrBox2, Me.Label5})
        Me.Frame3.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Frame3.Location = New System.Drawing.Point(198, 206)
        Me.Frame3.Name = "Frame3"
        Me.Frame3.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Frame3.Size = New System.Drawing.Size(185, 49)
        Me.Frame3.TabIndex = 17
        Me.Frame3.TabStop = False
        Me.Frame3.Text = "Address of device 2"
        '
        'YrAdrBox2
        '
        Me.YrAdrBox2.BackColor = System.Drawing.SystemColors.Window
        Me.YrAdrBox2.Cursor = System.Windows.Forms.Cursors.Default
        Me.YrAdrBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.YrAdrBox2.ForeColor = System.Drawing.SystemColors.WindowText
        Me.YrAdrBox2.Location = New System.Drawing.Point(104, 18)
        Me.YrAdrBox2.Name = "YrAdrBox2"
        Me.YrAdrBox2.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.YrAdrBox2.Size = New System.Drawing.Size(53, 21)
        Me.YrAdrBox2.TabIndex = 9
        '
        'Label5
        '
        Me.Label5.BackColor = System.Drawing.SystemColors.Control
        Me.Label5.Cursor = System.Windows.Forms.Cursors.Default
        Me.Label5.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Label5.Location = New System.Drawing.Point(24, 22)
        Me.Label5.Name = "Label5"
        Me.Label5.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label5.Size = New System.Drawing.Size(73, 19)
        Me.Label5.TabIndex = 18
        Me.Label5.Text = "Address ="
        '
        'Frame2
        '
        Me.Frame2.BackColor = System.Drawing.SystemColors.Control
        Me.Frame2.Controls.AddRange(New System.Windows.Forms.Control() {Me.PollSts, Me.PollGo, Me.PollSet, Me.Label3, Me.Label2, Me.Label1})
        Me.Frame2.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Frame2.Location = New System.Drawing.Point(8, 4)
        Me.Frame2.Name = "Frame2"
        Me.Frame2.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Frame2.Size = New System.Drawing.Size(443, 167)
        Me.Frame2.TabIndex = 12
        Me.Frame2.TabStop = False
        Me.Frame2.Text = "Information (Return Code)"
        '
        'PollSts
        '
        Me.PollSts.AcceptsReturn = True
        Me.PollSts.AutoSize = False
        Me.PollSts.BackColor = System.Drawing.SystemColors.Window
        Me.PollSts.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.PollSts.ForeColor = System.Drawing.SystemColors.WindowText
        Me.PollSts.Location = New System.Drawing.Point(10, 136)
        Me.PollSts.MaxLength = 0
        Me.PollSts.Name = "PollSts"
        Me.PollSts.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.PollSts.Size = New System.Drawing.Size(425, 24)
        Me.PollSts.TabIndex = 6
        Me.PollSts.Text = ""
        '
        'PollGo
        '
        Me.PollGo.AcceptsReturn = True
        Me.PollGo.AutoSize = False
        Me.PollGo.BackColor = System.Drawing.SystemColors.Window
        Me.PollGo.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.PollGo.ForeColor = System.Drawing.SystemColors.WindowText
        Me.PollGo.Location = New System.Drawing.Point(10, 90)
        Me.PollGo.MaxLength = 0
        Me.PollGo.Name = "PollGo"
        Me.PollGo.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.PollGo.Size = New System.Drawing.Size(425, 24)
        Me.PollGo.TabIndex = 5
        Me.PollGo.Text = ""
        '
        'PollSet
        '
        Me.PollSet.AcceptsReturn = True
        Me.PollSet.AutoSize = False
        Me.PollSet.BackColor = System.Drawing.SystemColors.Window
        Me.PollSet.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.PollSet.ForeColor = System.Drawing.SystemColors.WindowText
        Me.PollSet.Location = New System.Drawing.Point(10, 46)
        Me.PollSet.MaxLength = 0
        Me.PollSet.Name = "PollSet"
        Me.PollSet.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.PollSet.Size = New System.Drawing.Size(425, 24)
        Me.PollSet.TabIndex = 4
        Me.PollSet.Text = ""
        '
        'Label3
        '
        Me.Label3.BackColor = System.Drawing.SystemColors.Control
        Me.Label3.Cursor = System.Windows.Forms.Cursors.Default
        Me.Label3.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Label3.Location = New System.Drawing.Point(12, 118)
        Me.Label3.Name = "Label3"
        Me.Label3.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label3.Size = New System.Drawing.Size(95, 19)
        Me.Label3.TabIndex = 15
        Me.Label3.Text = "Polling Status"
        '
        'Label2
        '
        Me.Label2.BackColor = System.Drawing.SystemColors.Control
        Me.Label2.Cursor = System.Windows.Forms.Cursors.Default
        Me.Label2.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Label2.Location = New System.Drawing.Point(12, 74)
        Me.Label2.Name = "Label2"
        Me.Label2.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label2.Size = New System.Drawing.Size(127, 19)
        Me.Label2.TabIndex = 14
        Me.Label2.Text = "Parallel Poll Result"
        '
        'Label1
        '
        Me.Label1.BackColor = System.Drawing.SystemColors.Control
        Me.Label1.Cursor = System.Windows.Forms.Cursors.Default
        Me.Label1.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Label1.Location = New System.Drawing.Point(12, 28)
        Me.Label1.Name = "Label1"
        Me.Label1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label1.Size = New System.Drawing.Size(75, 19)
        Me.Label1.TabIndex = 13
        Me.Label1.Text = "Polling Set"
        '
        'Frame1
        '
        Me.Frame1.BackColor = System.Drawing.SystemColors.Control
        Me.Frame1.Controls.AddRange(New System.Windows.Forms.Control() {Me.YrAdrBox1, Me.Label4})
        Me.Frame1.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Frame1.Location = New System.Drawing.Point(8, 206)
        Me.Frame1.Name = "Frame1"
        Me.Frame1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Frame1.Size = New System.Drawing.Size(181, 49)
        Me.Frame1.TabIndex = 11
        Me.Frame1.TabStop = False
        Me.Frame1.Text = "Address of device 1"
        '
        'YrAdrBox1
        '
        Me.YrAdrBox1.BackColor = System.Drawing.SystemColors.Window
        Me.YrAdrBox1.Cursor = System.Windows.Forms.Cursors.Default
        Me.YrAdrBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.YrAdrBox1.ForeColor = System.Drawing.SystemColors.WindowText
        Me.YrAdrBox1.Location = New System.Drawing.Point(96, 18)
        Me.YrAdrBox1.Name = "YrAdrBox1"
        Me.YrAdrBox1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.YrAdrBox1.Size = New System.Drawing.Size(53, 21)
        Me.YrAdrBox1.TabIndex = 8
        '
        'Label4
        '
        Me.Label4.BackColor = System.Drawing.SystemColors.Control
        Me.Label4.Cursor = System.Windows.Forms.Cursors.Default
        Me.Label4.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Label4.Location = New System.Drawing.Point(24, 22)
        Me.Label4.Name = "Label4"
        Me.Label4.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label4.Size = New System.Drawing.Size(67, 19)
        Me.Label4.TabIndex = 16
        Me.Label4.Text = "Address ="
        '
        'Polling
        '
        Me.Polling.BackColor = System.Drawing.SystemColors.Control
        Me.Polling.Cursor = System.Windows.Forms.Cursors.Default
        Me.Polling.Enabled = False
        Me.Polling.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Polling.Location = New System.Drawing.Point(392, 216)
        Me.Polling.Name = "Polling"
        Me.Polling.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Polling.Size = New System.Drawing.Size(147, 39)
        Me.Polling.TabIndex = 10
        Me.Polling.Text = "&Parallel Poll"
        '
        'Label6
        '
        Me.Label6.BackColor = System.Drawing.SystemColors.Control
        Me.Label6.Cursor = System.Windows.Forms.Cursors.Default
        Me.Label6.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Label6.Location = New System.Drawing.Point(8, 182)
        Me.Label6.Name = "Label6"
        Me.Label6.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label6.Size = New System.Drawing.Size(89, 17)
        Me.Label6.TabIndex = 19
        Me.Label6.Text = "Return value"
        '
        'Parallel
        '
        Me.ClientSize = New System.Drawing.Size(547, 267)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.DelRet, Me.TextRet, Me.PollDel, Me.Exit_Renamed, Me.Initialize, Me.Frame3, Me.Frame2, Me.Frame1, Me.Polling, Me.Label6})
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        Me.Location = New System.Drawing.Point(74, 122)
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "Parallel"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.Manual
        Me.Text = "Parallel Poll"
        Me.Frame3.ResumeLayout(False)
        Me.Frame2.ResumeLayout(False)
        Me.Frame1.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub
#End Region 
#Region "Upgrade Support "
	Private Shared m_vb6FormDefInstance As Parallel
	Private Shared m_InitializingDefInstance As Boolean
	Public Shared Property DefInstance() As Parallel
		Get
			If m_vb6FormDefInstance Is Nothing OrElse m_vb6FormDefInstance.IsDisposed Then
				m_InitializingDefInstance = True
				m_vb6FormDefInstance = New Parallel()
				m_InitializingDefInstance = False
			End If
			DefInstance = m_vb6FormDefInstance
		End Get
		Set
			m_vb6FormDefInstance = Value
		End Set
	End Property
#End Region 
    Dim Pstb(15) As Integer                 'An array of status byte
    Dim Pstb2(15) As Integer                'For the 2nd frustum
    Dim PpollData As Integer                'As the result that it was poll parallel
    Dim Yradr2 As Integer                   'The Address of device address 2nd frustum
    Dim Cmd2(50) As Integer                 'It is parallel message (command)/, and use
    Dim Adrs As Integer                     'It is used at the time of device making
    Dim ErrText As String                   'Text for display
    Dim Srlen As Integer                    'A length of a character string
    Dim gChCmd As GCHandle                  'GCHandle for cmd array
    Dim gChPstb As GCHandle                 'GCHandle for Pstb array
    Dim pPstb As IntPtr                     'IntPtr for Pstb array
    Dim gChCmd2 As GCHandle                 'GCHandle for cmd2 array
    Dim gChPstb2 As GCHandle                'GCHandle for Pstb2 array
    Dim pPstb2 As IntPtr                    'IntPtr for Pstb2 array
    Dim pCmd2 As IntPtr                     'IntPtr for cmd2 array
	
	Private Sub Parallel_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load '[ Form load ]
		
        For Adrs = 0 To 30                  'Making of Address of device
            YrAdrBox1.Items.Add(CStr(Adrs))
            YrAdrBox2.Items.Add(CStr(Adrs))
        Next Adrs

        YrAdrBox1.Text = CStr(1)            'Initial setting
        YrAdrBox2.Text = CStr(2)            'Initial setting

        'Specify Pinned handle to Cmd
        If gChCmd.IsAllocated = False Then
            gChCmd = GCHandle.Alloc(Cmd, GCHandleType.Pinned)
        End If
        If gChCmd2.IsAllocated = False Then
            gChCmd2 = GCHandle.Alloc(Cmd2, GCHandleType.Pinned)
        End If
        'Specify Pinned handle to Pstb
        If gChPstb.IsAllocated = False Then
            gChPstb = GCHandle.Alloc(Pstb, GCHandleType.Pinned)
        End If
        If gChPstb2.IsAllocated = False Then
            gChPstb2 = GCHandle.Alloc(Pstb2, GCHandleType.Pinned)
        End If
        'Get address object by Pinned handle
        pCmd = gChCmd.AddrOfPinnedObject()
        pCmd2 = gChCmd2.AddrOfPinnedObject()
        pPstb = gChPstb.AddrOfPinnedObject()
        pPstb2 = gChPstb2.AddrOfPinnedObject()
		
	End Sub
	
	Private Sub Initialize_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Initialize.Click '[ Initialize ]
		
        Ret = GpibInit(ErrText)             'SubClass.bas
		If Ret = 1 Then GoTo Err_Renamed
		
		Polling.Enabled = True
		
        If YrAdrBox1.Items.Count = 31 Then  'MyAddress is deleted from a list.
            YrAdrBox1.Items.RemoveAt((MyAddr))
            YrAdrBox1.SelectedIndex = 0
            YrAdrBox2.Items.RemoveAt((MyAddr))
            YrAdrBox2.SelectedIndex = 1
        End If
        If Mode = 1 Then ErrText = "This equipment is not a master."
        GoTo Err_Renamed

Err_Renamed:  'If an error was detected, it is displayed
        TextRet.Text = ErrText
		
	End Sub
	
	Private Sub Polling_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Polling.Click '[ Polling ]
		
        Dim Stppu As Integer                'Setting of PPU
		
        PollSet.Text = ""                   'Initialization of a text
		PollGo.Text = ""
		PollSts.Text = ""
		TextRet.Text = ""
		
		For Cnt = 0 To 15
            Pstb(Cnt) = 0                   'Initialization of parameter
            Pstb2(Cnt) = 0                  'Initialization of parameter
		Next 
        Cmd(0) = 2                          'The number of a listener
        Cmd(1) = YrAddr                     'The 1st listener
        Cmd(2) = &H69S                      'Distribution of a line(69H = DIO2)
        Cmd(3) = Yradr2                     'The 2nd listener
        Cmd(4) = &H6AS                      'Distribution of a line(6AH = DIO3)
        Stppu = 1                           'Use of PPU
		
        Ret = GpStppoll(pCmd, Stppu)      'A layout of a line for a responded output of a parallel pole
		If CheckRet("GpStppoll", Ret, ErrText) = 1 Then GoTo Err_Renamed
		PollSet.Text = ErrText
		
        Ret = GpExppoll(PpollData)          'Performance of parallel-poll
		If CheckRet("GpExppoll", Ret, ErrText) = 1 Then GoTo Err_Renamed
		PollGo.Text = ErrText
		
        Select Case PpollData               'At a result of parallel-poll an analysis
            Case 2                          'Data Line Bit = 00000010(DIO2)
                Cmd(0) = 1                  'The number of a listener
                Cmd(1) = YrAddr             'The 1st listener
                Ret = GpPoll(pCmd, pPstb) 'Performance of serial-poll
                If CheckRet("GpPoll_1", Ret, ErrText) = 1 Then GoTo Err_Renamed
                PollSts.Text = "Talker Address =[ " & Cmd(Pstb(0)) & " ] StatusByte = [ " & Hex(Pstb(Pstb(0))) & " ]H"
            Case 4                          'Data Line Bit = 00000100(DIO3)
                Cmd(0) = 1                  'The number of a listener
                Cmd(1) = Yradr2             'The 2nd listener
                Ret = GpPoll(pCmd, pPstb) 'Performance of serial-poll
                If CheckRet("GpPoll_2", Ret, ErrText) = 1 Then GoTo Err_Renamed
                PollSts.Text = "Talker Address =[ " & Cmd(Pstb(0)) & " ] StatusByte = [ " & Hex(Pstb(Pstb(0))) & " ]H"
            Case 6                          'Data Line Bit = 00000110(DIO2 + DIO3)
                Cmd(0) = 1                  'The number of a listener
                Cmd(1) = YrAddr             'The 1st address
                Ret = GpPoll(pCmd, pPstb) 'Performance of serial-poll
                If CheckRet("GpPoll_1", Ret, ErrText) = 1 Then GoTo Err_Renamed
                Cmd2(0) = 1                 'The number of a listener
                Cmd2(1) = Yradr2            'The 2nd listener
                Ret = GpPoll(pCmd2, pPstb2) 'Performance of serial-poll
                If CheckRet("GpPoll_2", Ret, ErrText) = 1 Then GoTo Err_Renamed
                PollSts.Text = "Talker =[ " & Cmd(Pstb(0)) & " ] StatusByte = [ " & Hex(Pstb(Pstb(0))) & " ] H + Talker =[ " & Cmd2(Pstb2(0)) & " ]  StatusByte =[ " & Hex(Pstb2(Pstb2(0))) & " ] H"
            Case Else
                ErrText = "There was not SRQ."
        End Select

Err_Renamed:
        TextRet.Text = ErrText
		
	End Sub
	
    Private Sub YrAdrBox1_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles YrAdrBox1.SelectedIndexChanged '[ Change of the 1st Address of device ]

        YrAddr = CInt(YrAdrBox1.Text)

    End Sub

    Private Sub YrAdrBox2_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles YrAdrBox2.SelectedIndexChanged '[ Change of the 2nd Address of device ]

        Yradr2 = CInt(YrAdrBox2.Text)

    End Sub

    Private Sub PollDel_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles PollDel.Click '[ An erase of a polling text ]

        PollSet.Text = ""
        PollGo.Text = ""
        PollSts.Text = ""

    End Sub

    Private Sub DelRet_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles DelRet.Click '[ An erase of a returning value ]

        TextRet.Text = ""

    End Sub

    Private Sub Exit_Renamed_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Exit_Renamed.Click '[ Exit ]

        Ret = GpibExit()                    'SubClass.bas
        Me.Close()

    End Sub

    Private Sub Form1_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed

        'GCHandle free
        If gChCmd.IsAllocated = True Then
            gChCmd.Free()
        End If
        If gChPstb.IsAllocated = True Then
            gChPstb.Free()
        End If
        If gChCmd2.IsAllocated = True Then
            gChCmd2.Free()
        End If
        If gChPstb2.IsAllocated = True Then
            gChPstb2.Free()
        End If
    End Sub
End Class