Option Strict Off
Option Explicit On 
Imports VB = Microsoft.VisualBasic
Public Class Slave
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    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

    '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.
    Public WithEvents Frame5 As System.Windows.Forms.GroupBox
    Public WithEvents optSrqSend As System.Windows.Forms.RadioButton
    Public WithEvents optSrqNotSend As System.Windows.Forms.RadioButton
    Public WithEvents txtSPollStb As System.Windows.Forms.TextBox
    Public WithEvents cmdSendSrq As System.Windows.Forms.Button
    Public WithEvents Label6 As System.Windows.Forms.Label
    Public WithEvents Label5 As System.Windows.Forms.Label
    Public WithEvents Frame4 As System.Windows.Forms.GroupBox
    Public WithEvents optPPollResponseIst1 As System.Windows.Forms.RadioButton
    Public WithEvents cmdParallelpollSetting As System.Windows.Forms.Button
    Public WithEvents optPPollResponseIst0 As System.Windows.Forms.RadioButton
    Public WithEvents optPPollResponseSrq As System.Windows.Forms.RadioButton
    Public WithEvents optPPollResponseNot As System.Windows.Forms.RadioButton
    Public WithEvents Frame2 As System.Windows.Forms.GroupBox
    Public WithEvents cmdRec As System.Windows.Forms.Button
    Public WithEvents cmdSend As System.Windows.Forms.Button
    Public WithEvents txtRec As System.Windows.Forms.TextBox
    Public WithEvents txtSend As System.Windows.Forms.TextBox
    Public WithEvents cmdExit As System.Windows.Forms.Button
    Public WithEvents cmdInit As System.Windows.Forms.Button
    Public WithEvents Frame1 As System.Windows.Forms.GroupBox
    Public WithEvents cboEoi As System.Windows.Forms.ComboBox
    Public WithEvents cboDelim As System.Windows.Forms.ComboBox
    Public WithEvents txtMyAddr As System.Windows.Forms.TextBox
    Public WithEvents txtDevName As System.Windows.Forms.TextBox
    Public WithEvents Label4 As System.Windows.Forms.Label
    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 cmdRetDel As System.Windows.Forms.Button
    Public WithEvents cmdDataDel As System.Windows.Forms.Button
    Public WithEvents Frame3 As System.Windows.Forms.GroupBox
    Public WithEvents lstRet As System.Windows.Forms.ListBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Frame5 = New System.Windows.Forms.GroupBox()
        Me.optSrqSend = New System.Windows.Forms.RadioButton()
        Me.optSrqNotSend = New System.Windows.Forms.RadioButton()
        Me.txtSPollStb = New System.Windows.Forms.TextBox()
        Me.cmdSendSrq = New System.Windows.Forms.Button()
        Me.Label6 = New System.Windows.Forms.Label()
        Me.Label5 = New System.Windows.Forms.Label()
        Me.Frame4 = New System.Windows.Forms.GroupBox()
        Me.optPPollResponseIst1 = New System.Windows.Forms.RadioButton()
        Me.cmdParallelpollSetting = New System.Windows.Forms.Button()
        Me.optPPollResponseIst0 = New System.Windows.Forms.RadioButton()
        Me.optPPollResponseSrq = New System.Windows.Forms.RadioButton()
        Me.optPPollResponseNot = New System.Windows.Forms.RadioButton()
        Me.Frame2 = New System.Windows.Forms.GroupBox()
        Me.cmdRec = New System.Windows.Forms.Button()
        Me.cmdSend = New System.Windows.Forms.Button()
        Me.txtRec = New System.Windows.Forms.TextBox()
        Me.txtSend = New System.Windows.Forms.TextBox()
        Me.cmdExit = New System.Windows.Forms.Button()
        Me.cmdInit = New System.Windows.Forms.Button()
        Me.Frame1 = New System.Windows.Forms.GroupBox()
        Me.cboEoi = New System.Windows.Forms.ComboBox()
        Me.cboDelim = New System.Windows.Forms.ComboBox()
        Me.txtMyAddr = New System.Windows.Forms.TextBox()
        Me.txtDevName = New System.Windows.Forms.TextBox()
        Me.Label4 = New System.Windows.Forms.Label()
        Me.Label3 = New System.Windows.Forms.Label()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.cmdRetDel = New System.Windows.Forms.Button()
        Me.cmdDataDel = New System.Windows.Forms.Button()
        Me.Frame3 = New System.Windows.Forms.GroupBox()
        Me.lstRet = New System.Windows.Forms.ListBox()
        Me.Frame5.SuspendLayout()
        Me.Frame4.SuspendLayout()
        Me.Frame2.SuspendLayout()
        Me.Frame1.SuspendLayout()
        Me.Frame3.SuspendLayout()
        Me.SuspendLayout()
        '
        'Frame5
        '
        Me.Frame5.BackColor = System.Drawing.SystemColors.Control
        Me.Frame5.Controls.AddRange(New System.Windows.Forms.Control() {Me.optSrqSend, Me.optSrqNotSend, Me.txtSPollStb, Me.cmdSendSrq, Me.Label6, Me.Label5})
        Me.Frame5.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Frame5.Location = New System.Drawing.Point(566, 12)
        Me.Frame5.Name = "Frame5"
        Me.Frame5.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Frame5.Size = New System.Drawing.Size(186, 164)
        Me.Frame5.TabIndex = 39
        Me.Frame5.TabStop = False
        Me.Frame5.Text = "Serial poll response"
        '
        'optSrqSend
        '
        Me.optSrqSend.BackColor = System.Drawing.SystemColors.Control
        Me.optSrqSend.Cursor = System.Windows.Forms.Cursors.Default
        Me.optSrqSend.ForeColor = System.Drawing.SystemColors.ControlText
        Me.optSrqSend.Location = New System.Drawing.Point(8, 45)
        Me.optSrqSend.Name = "optSrqSend"
        Me.optSrqSend.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.optSrqSend.Size = New System.Drawing.Size(113, 19)
        Me.optSrqSend.TabIndex = 15
        Me.optSrqSend.TabStop = True
        Me.optSrqSend.Text = "Transmit SRQ"
        '
        'optSrqNotSend
        '
        Me.optSrqNotSend.BackColor = System.Drawing.SystemColors.Control
        Me.optSrqNotSend.Checked = True
        Me.optSrqNotSend.Cursor = System.Windows.Forms.Cursors.Default
        Me.optSrqNotSend.ForeColor = System.Drawing.SystemColors.ControlText
        Me.optSrqNotSend.Location = New System.Drawing.Point(8, 19)
        Me.optSrqNotSend.Name = "optSrqNotSend"
        Me.optSrqNotSend.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.optSrqNotSend.Size = New System.Drawing.Size(113, 19)
        Me.optSrqNotSend.TabIndex = 14
        Me.optSrqNotSend.TabStop = True
        Me.optSrqNotSend.Text = "Not transmit SRQ"
        '
        'txtSPollStb
        '
        Me.txtSPollStb.AcceptsReturn = True
        Me.txtSPollStb.AutoSize = False
        Me.txtSPollStb.BackColor = System.Drawing.SystemColors.Window
        Me.txtSPollStb.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.txtSPollStb.ForeColor = System.Drawing.SystemColors.WindowText
        Me.txtSPollStb.ImeMode = System.Windows.Forms.ImeMode.Off
        Me.txtSPollStb.Location = New System.Drawing.Point(112, 69)
        Me.txtSPollStb.MaxLength = 3
        Me.txtSPollStb.Name = "txtSPollStb"
        Me.txtSPollStb.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.txtSPollStb.Size = New System.Drawing.Size(64, 25)
        Me.txtSPollStb.TabIndex = 13
        Me.txtSPollStb.Text = "0"
        '
        'cmdSendSrq
        '
        Me.cmdSendSrq.BackColor = System.Drawing.SystemColors.Control
        Me.cmdSendSrq.Cursor = System.Windows.Forms.Cursors.Default
        Me.cmdSendSrq.ForeColor = System.Drawing.SystemColors.ControlText
        Me.cmdSendSrq.Location = New System.Drawing.Point(8, 125)
        Me.cmdSendSrq.Name = "cmdSendSrq"
        Me.cmdSendSrq.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdSendSrq.Size = New System.Drawing.Size(136, 29)
        Me.cmdSendSrq.TabIndex = 12
        Me.cmdSendSrq.Text = "Reflect set value"
        '
        '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, 98)
        Me.Label6.Name = "Label6"
        Me.Label6.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label6.Size = New System.Drawing.Size(120, 20)
        Me.Label6.TabIndex = 25
        Me.Label6.Text = "(Set from 0 to 255)"
        '
        '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(8, 71)
        Me.Label5.Name = "Label5"
        Me.Label5.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label5.Size = New System.Drawing.Size(97, 20)
        Me.Label5.TabIndex = 23
        Me.Label5.Text = "Status byte ="
        '
        'Frame4
        '
        Me.Frame4.BackColor = System.Drawing.SystemColors.Control
        Me.Frame4.Controls.AddRange(New System.Windows.Forms.Control() {Me.optPPollResponseIst1, Me.cmdParallelpollSetting, Me.optPPollResponseIst0, Me.optPPollResponseSrq, Me.optPPollResponseNot})
        Me.Frame4.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Frame4.Location = New System.Drawing.Point(566, 189)
        Me.Frame4.Name = "Frame4"
        Me.Frame4.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Frame4.Size = New System.Drawing.Size(186, 187)
        Me.Frame4.TabIndex = 36
        Me.Frame4.TabStop = False
        Me.Frame4.Text = "Parallel poll response"
        '
        'optPPollResponseIst1
        '
        Me.optPPollResponseIst1.BackColor = System.Drawing.SystemColors.Control
        Me.optPPollResponseIst1.Cursor = System.Windows.Forms.Cursors.Default
        Me.optPPollResponseIst1.ForeColor = System.Drawing.SystemColors.ControlText
        Me.optPPollResponseIst1.Location = New System.Drawing.Point(8, 81)
        Me.optPPollResponseIst1.Name = "optPPollResponseIst1"
        Me.optPPollResponseIst1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.optPPollResponseIst1.Size = New System.Drawing.Size(176, 20)
        Me.optPPollResponseIst1.TabIndex = 19
        Me.optPPollResponseIst1.TabStop = True
        Me.optPPollResponseIst1.Text = "ISTbit response(IST = 1) "
        '
        'cmdParallelpollSetting
        '
        Me.cmdParallelpollSetting.BackColor = System.Drawing.SystemColors.Control
        Me.cmdParallelpollSetting.Cursor = System.Windows.Forms.Cursors.Default
        Me.cmdParallelpollSetting.ForeColor = System.Drawing.SystemColors.ControlText
        Me.cmdParallelpollSetting.Location = New System.Drawing.Point(8, 146)
        Me.cmdParallelpollSetting.Name = "cmdParallelpollSetting"
        Me.cmdParallelpollSetting.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdParallelpollSetting.Size = New System.Drawing.Size(128, 29)
        Me.cmdParallelpollSetting.TabIndex = 16
        Me.cmdParallelpollSetting.Text = "Reflect  set  value"
        '
        'optPPollResponseIst0
        '
        Me.optPPollResponseIst0.BackColor = System.Drawing.SystemColors.Control
        Me.optPPollResponseIst0.Cursor = System.Windows.Forms.Cursors.Default
        Me.optPPollResponseIst0.ForeColor = System.Drawing.SystemColors.ControlText
        Me.optPPollResponseIst0.Location = New System.Drawing.Point(8, 50)
        Me.optPPollResponseIst0.Name = "optPPollResponseIst0"
        Me.optPPollResponseIst0.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.optPPollResponseIst0.Size = New System.Drawing.Size(170, 20)
        Me.optPPollResponseIst0.TabIndex = 18
        Me.optPPollResponseIst0.TabStop = True
        Me.optPPollResponseIst0.Text = "ISTbit response(IST = 0)"
        '
        'optPPollResponseSrq
        '
        Me.optPPollResponseSrq.BackColor = System.Drawing.SystemColors.Control
        Me.optPPollResponseSrq.Cursor = System.Windows.Forms.Cursors.Default
        Me.optPPollResponseSrq.ForeColor = System.Drawing.SystemColors.ControlText
        Me.optPPollResponseSrq.Location = New System.Drawing.Point(8, 112)
        Me.optPPollResponseSrq.Name = "optPPollResponseSrq"
        Me.optPPollResponseSrq.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.optPPollResponseSrq.Size = New System.Drawing.Size(144, 18)
        Me.optPPollResponseSrq.TabIndex = 20
        Me.optPPollResponseSrq.TabStop = True
        Me.optPPollResponseSrq.Text = "Response with SRQ"
        '
        'optPPollResponseNot
        '
        Me.optPPollResponseNot.BackColor = System.Drawing.SystemColors.Control
        Me.optPPollResponseNot.Checked = True
        Me.optPPollResponseNot.Cursor = System.Windows.Forms.Cursors.Default
        Me.optPPollResponseNot.ForeColor = System.Drawing.SystemColors.ControlText
        Me.optPPollResponseNot.Location = New System.Drawing.Point(8, 24)
        Me.optPPollResponseNot.Name = "optPPollResponseNot"
        Me.optPPollResponseNot.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.optPPollResponseNot.Size = New System.Drawing.Size(89, 19)
        Me.optPPollResponseNot.TabIndex = 17
        Me.optPPollResponseNot.TabStop = True
        Me.optPPollResponseNot.Text = "No response"
        '
        'Frame2
        '
        Me.Frame2.BackColor = System.Drawing.SystemColors.Control
        Me.Frame2.Controls.AddRange(New System.Windows.Forms.Control() {Me.cmdRec, Me.cmdSend, Me.txtRec, Me.txtSend})
        Me.Frame2.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Frame2.Location = New System.Drawing.Point(11, 125)
        Me.Frame2.Name = "Frame2"
        Me.Frame2.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Frame2.Size = New System.Drawing.Size(545, 94)
        Me.Frame2.TabIndex = 34
        Me.Frame2.TabStop = False
        Me.Frame2.Text = "Send / Receive data"
        '
        'cmdRec
        '
        Me.cmdRec.BackColor = System.Drawing.SystemColors.Control
        Me.cmdRec.Cursor = System.Windows.Forms.Cursors.Default
        Me.cmdRec.ForeColor = System.Drawing.SystemColors.ControlText
        Me.cmdRec.Location = New System.Drawing.Point(430, 56)
        Me.cmdRec.Name = "cmdRec"
        Me.cmdRec.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdRec.Size = New System.Drawing.Size(105, 29)
        Me.cmdRec.TabIndex = 7
        Me.cmdRec.Text = "Receive"
        '
        'cmdSend
        '
        Me.cmdSend.BackColor = System.Drawing.SystemColors.Control
        Me.cmdSend.Cursor = System.Windows.Forms.Cursors.Default
        Me.cmdSend.ForeColor = System.Drawing.SystemColors.ControlText
        Me.cmdSend.Location = New System.Drawing.Point(430, 19)
        Me.cmdSend.Name = "cmdSend"
        Me.cmdSend.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdSend.Size = New System.Drawing.Size(105, 29)
        Me.cmdSend.TabIndex = 6
        Me.cmdSend.Text = "Send"
        '
        'txtRec
        '
        Me.txtRec.AcceptsReturn = True
        Me.txtRec.AutoSize = False
        Me.txtRec.BackColor = System.Drawing.SystemColors.Window
        Me.txtRec.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.txtRec.ForeColor = System.Drawing.SystemColors.WindowText
        Me.txtRec.Location = New System.Drawing.Point(8, 56)
        Me.txtRec.MaxLength = 0
        Me.txtRec.Name = "txtRec"
        Me.txtRec.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.txtRec.Size = New System.Drawing.Size(408, 29)
        Me.txtRec.TabIndex = 9
        Me.txtRec.Text = ""
        '
        'txtSend
        '
        Me.txtSend.AcceptsReturn = True
        Me.txtSend.AutoSize = False
        Me.txtSend.BackColor = System.Drawing.SystemColors.Window
        Me.txtSend.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.txtSend.ForeColor = System.Drawing.SystemColors.WindowText
        Me.txtSend.Location = New System.Drawing.Point(8, 19)
        Me.txtSend.MaxLength = 0
        Me.txtSend.Name = "txtSend"
        Me.txtSend.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.txtSend.Size = New System.Drawing.Size(408, 29)
        Me.txtSend.TabIndex = 8
        Me.txtSend.Text = ""
        '
        'cmdExit
        '
        Me.cmdExit.BackColor = System.Drawing.SystemColors.Control
        Me.cmdExit.Cursor = System.Windows.Forms.Cursors.Default
        Me.cmdExit.ForeColor = System.Drawing.SystemColors.ControlText
        Me.cmdExit.Location = New System.Drawing.Point(440, 72)
        Me.cmdExit.Name = "cmdExit"
        Me.cmdExit.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdExit.Size = New System.Drawing.Size(105, 29)
        Me.cmdExit.TabIndex = 1
        Me.cmdExit.Text = "Exit"
        '
        'cmdInit
        '
        Me.cmdInit.BackColor = System.Drawing.SystemColors.Control
        Me.cmdInit.Cursor = System.Windows.Forms.Cursors.Default
        Me.cmdInit.ForeColor = System.Drawing.SystemColors.ControlText
        Me.cmdInit.Location = New System.Drawing.Point(440, 28)
        Me.cmdInit.Name = "cmdInit"
        Me.cmdInit.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdInit.Size = New System.Drawing.Size(105, 29)
        Me.cmdInit.TabIndex = 0
        Me.cmdInit.Text = "Initialize"
        '
        'Frame1
        '
        Me.Frame1.BackColor = System.Drawing.SystemColors.Control
        Me.Frame1.Controls.AddRange(New System.Windows.Forms.Control() {Me.cboEoi, Me.cboDelim, Me.txtMyAddr, Me.txtDevName, Me.Label4, Me.Label3, Me.Label2, Me.Label1})
        Me.Frame1.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Frame1.Location = New System.Drawing.Point(11, 12)
        Me.Frame1.Name = "Frame1"
        Me.Frame1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Frame1.Size = New System.Drawing.Size(421, 100)
        Me.Frame1.TabIndex = 31
        Me.Frame1.TabStop = False
        Me.Frame1.Text = "Self information"
        '
        'cboEoi
        '
        Me.cboEoi.BackColor = System.Drawing.SystemColors.Window
        Me.cboEoi.Cursor = System.Windows.Forms.Cursors.Default
        Me.cboEoi.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cboEoi.ForeColor = System.Drawing.SystemColors.WindowText
        Me.cboEoi.Items.AddRange(New Object() {"Not use", "Use"})
        Me.cboEoi.Location = New System.Drawing.Point(323, 64)
        Me.cboEoi.Name = "cboEoi"
        Me.cboEoi.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cboEoi.Size = New System.Drawing.Size(89, 24)
        Me.cboEoi.TabIndex = 5
        '
        'cboDelim
        '
        Me.cboDelim.BackColor = System.Drawing.SystemColors.Window
        Me.cboDelim.Cursor = System.Windows.Forms.Cursors.Default
        Me.cboDelim.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cboDelim.ForeColor = System.Drawing.SystemColors.WindowText
        Me.cboDelim.Items.AddRange(New Object() {"Not use", "CR+LF", "CR", "LF"})
        Me.cboDelim.Location = New System.Drawing.Point(112, 64)
        Me.cboDelim.Name = "cboDelim"
        Me.cboDelim.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cboDelim.Size = New System.Drawing.Size(96, 24)
        Me.cboDelim.TabIndex = 4
        '
        'txtMyAddr
        '
        Me.txtMyAddr.AcceptsReturn = True
        Me.txtMyAddr.AutoSize = False
        Me.txtMyAddr.BackColor = System.Drawing.SystemColors.Window
        Me.txtMyAddr.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.txtMyAddr.Enabled = False
        Me.txtMyAddr.ForeColor = System.Drawing.SystemColors.WindowText
        Me.txtMyAddr.Location = New System.Drawing.Point(323, 23)
        Me.txtMyAddr.MaxLength = 0
        Me.txtMyAddr.Name = "txtMyAddr"
        Me.txtMyAddr.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.txtMyAddr.Size = New System.Drawing.Size(64, 25)
        Me.txtMyAddr.TabIndex = 3
        Me.txtMyAddr.Text = ""
        '
        'txtDevName
        '
        Me.txtDevName.AcceptsReturn = True
        Me.txtDevName.AutoSize = False
        Me.txtDevName.BackColor = System.Drawing.SystemColors.Window
        Me.txtDevName.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.txtDevName.ForeColor = System.Drawing.SystemColors.WindowText
        Me.txtDevName.Location = New System.Drawing.Point(112, 23)
        Me.txtDevName.MaxLength = 0
        Me.txtDevName.Name = "txtDevName"
        Me.txtDevName.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.txtDevName.Size = New System.Drawing.Size(73, 25)
        Me.txtDevName.TabIndex = 2
        Me.txtDevName.Text = ""
        '
        '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(219, 64)
        Me.Label4.Name = "Label4"
        Me.Label4.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label4.Size = New System.Drawing.Size(57, 20)
        Me.Label4.TabIndex = 7
        Me.Label4.Text = "EOI ="
        '
        '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(8, 64)
        Me.Label3.Name = "Label3"
        Me.Label3.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label3.Size = New System.Drawing.Size(80, 20)
        Me.Label3.TabIndex = 5
        Me.Label3.Text = "Delimiter ="
        '
        '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(219, 25)
        Me.Label2.Name = "Label2"
        Me.Label2.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label2.Size = New System.Drawing.Size(101, 20)
        Me.Label2.TabIndex = 3
        Me.Label2.Text = "GPIB address ="
        '
        '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(8, 25)
        Me.Label1.Name = "Label1"
        Me.Label1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label1.Size = New System.Drawing.Size(96, 20)
        Me.Label1.TabIndex = 1
        Me.Label1.Text = "Device name ="
        '
        'cmdRetDel
        '
        Me.cmdRetDel.BackColor = System.Drawing.SystemColors.Control
        Me.cmdRetDel.Cursor = System.Windows.Forms.Cursors.Default
        Me.cmdRetDel.ForeColor = System.Drawing.SystemColors.ControlText
        Me.cmdRetDel.Location = New System.Drawing.Point(168, 346)
        Me.cmdRetDel.Name = "cmdRetDel"
        Me.cmdRetDel.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdRetDel.Size = New System.Drawing.Size(133, 30)
        Me.cmdRetDel.TabIndex = 11
        Me.cmdRetDel.Text = "Clear return code"
        '
        'cmdDataDel
        '
        Me.cmdDataDel.BackColor = System.Drawing.SystemColors.Control
        Me.cmdDataDel.Cursor = System.Windows.Forms.Cursors.Default
        Me.cmdDataDel.ForeColor = System.Drawing.SystemColors.ControlText
        Me.cmdDataDel.Location = New System.Drawing.Point(11, 346)
        Me.cmdDataDel.Name = "cmdDataDel"
        Me.cmdDataDel.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdDataDel.Size = New System.Drawing.Size(133, 30)
        Me.cmdDataDel.TabIndex = 10
        Me.cmdDataDel.Text = "Clear data"
        '
        'Frame3
        '
        Me.Frame3.BackColor = System.Drawing.SystemColors.Control
        Me.Frame3.Controls.AddRange(New System.Windows.Forms.Control() {Me.lstRet})
        Me.Frame3.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Frame3.Location = New System.Drawing.Point(11, 232)
        Me.Frame3.Name = "Frame3"
        Me.Frame3.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Frame3.Size = New System.Drawing.Size(545, 94)
        Me.Frame3.TabIndex = 35
        Me.Frame3.TabStop = False
        Me.Frame3.Text = "Return code"
        '
        'lstRet
        '
        Me.lstRet.BackColor = System.Drawing.SystemColors.Window
        Me.lstRet.Cursor = System.Windows.Forms.Cursors.Default
        Me.lstRet.ForeColor = System.Drawing.SystemColors.WindowText
        Me.lstRet.ItemHeight = 16
        Me.lstRet.Location = New System.Drawing.Point(8, 19)
        Me.lstRet.Name = "lstRet"
        Me.lstRet.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.lstRet.Size = New System.Drawing.Size(529, 52)
        Me.lstRet.TabIndex = 28
        '
        'Slave
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15)
        Me.ClientSize = New System.Drawing.Size(762, 384)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Frame5, Me.Frame4, Me.Frame2, Me.cmdExit, Me.cmdInit, Me.Frame1, Me.cmdRetDel, Me.cmdDataDel, Me.Frame3})
        Me.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "Slave"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Slave Sample"
        Me.Frame5.ResumeLayout(False)
        Me.Frame4.ResumeLayout(False)
        Me.Frame2.ResumeLayout(False)
        Me.Frame1.ResumeLayout(False)
        Me.Frame3.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private mlngRet As Integer
    Private mintDevId As Short

    '**************************************************************************************************
    '   Set initial value
    '**************************************************************************************************
    Private Sub Slave_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
        txtDevName.Text = "GPIB000"
        cboDelim.SelectedIndex = 1 'CR+LF
        cboEoi.SelectedIndex = 1 'Use
        txtSend.Text = "CONTEC Slave Sample" 'Default data to be sent
        txtSPollStb.Text = CStr(0)
    End Sub

    '**************************************************************************************************
    '   Ending process(force to end)
    '**************************************************************************************************
    Private Sub Slave_Closed(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Closed
        Call cmdExit_Click(cmdExit, New System.EventArgs())
    End Sub

    '**************************************************************************************************
    '   Display transmitted string to list box of "Return code"(sub routine)
    '   Return value: TRUE(normally), FALSE(abnormally)
    '**************************************************************************************************
    Private Function funcSetlstRet(ByRef strRet As String) As Boolean
        Dim blnRet As Boolean
        blnRet = False 'Return value

        If Len(strRet) = 0 Then 'Check the number of the string
            blnRet = True
        Else
            If lstRet.Items.Count >= 256 Then 'Set the maximum number of list box
                lstRet.Items.RemoveAt(0)
                lstRet.Items.Add(strRet)
            Else
                lstRet.Items.Add(strRet)
            End If
            lstRet.SelectedIndex = lstRet.Items.Count - 1
        End If
        funcSetlstRet = blnRet
    End Function
    '**************************************************************************************************
    '   Set the target (sub routine)
    '   Function: Set Equipment ID, Delimiter and EOI
    '   Return value: TRUE(normally), FALSE(abnormally)
    '**************************************************************************************************
    Private Function funcSetParam() As Boolean

        Dim Delim As Short
        Dim Eoi As Short
        Dim Eos As Short
        Dim strTmp As System.Text.StringBuilder

        'Set delimiter and EOI line
        Delim = cboDelim.SelectedIndex
        Eoi = cboEoi.SelectedIndex
        Eos = 0
        mlngRet = GpibSetDelim(mintDevId, Delim, Eoi, Eos)

        'Process return value
        If mlngRet <> 0 Then
            strTmp = New System.Text.StringBuilder("", 256)
            Call GpibGetErrorString(mlngRet, strTmp)
            Call funcSetlstRet(strTmp.ToString)
        Else
            'Display
            strTmp = New System.Text.StringBuilder("[Partner apparatus setting] completed normally")
            Call funcSetlstRet(strTmp.ToString)
        End If

        funcSetParam = True

    End Function

    '**************************************************************************************************
    '   Initialization
    '   Function: Get Device ID from device name
    '**************************************************************************************************
    Private Sub cmdInit_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdInit.Click
        Dim strTmp As System.Text.StringBuilder
        Dim lngData As Integer

        'Perform initialization function
        mlngRet = GpibInit(txtDevName.Text, mintDevId)
        'Process return value
        If mlngRet <> 0 Then
            strTmp = New System.Text.StringBuilder("", 256)
            Call GpibGetErrorString(mlngRet, strTmp)
            Call funcSetlstRet(strTmp.ToString)
        Else
            'When got Device ID normally
            strTmp = New System.Text.StringBuilder("GpibInit : Device ID = " & mintDevId)
            Call funcSetlstRet(strTmp.ToString)
            'Get devive address
            mlngRet = GpibGetStatus(mintDevId, &H8S, lngData)
            If mlngRet = 0 Then txtMyAddr.Text = CStr(lngData)
            'Confirm whether it is set to slave in property page
            mlngRet = GpibGetStatus(mintDevId, &HAS, lngData)
            'Confirm whether it is set to slave
            If (mlngRet = 0) And (lngData = 0) Then
                Call MsgBox("It is not a slave. Please set it to slave in property page", MsgBoxStyle.OKOnly)
            End If
            'Display
            strTmp = New System.Text.StringBuilder("[Initialize] completed normally")
            Call funcSetlstRet(strTmp.ToString)
        End If
        
        GpibSendIFC(mintDevId, 1)	'Send IFC
    End Sub
    '**************************************************************************************************
    '   Exit
    '   Function: Disable Device ID
    '**************************************************************************************************
    Private Sub cmdExit_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdExit.Click
        Dim strTmp As System.Text.StringBuilder

        'Proform exit function
        mlngRet = GpibExit(mintDevId)
        'Process return value
        If mlngRet <> 0 Then
            strTmp = New System.Text.StringBuilder("", 256)
            Call GpibGetErrorString(mlngRet, strTmp)
            Call funcSetlstRet(strTmp.ToString)
        End If
        End
    End Sub


    '**************************************************************************************************
    '   Send Data
    '   Function: Send data to slave device
    '**************************************************************************************************
    Private Sub cmdSend_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdSend.Click
        Dim SendLen As Integer
        Dim strTmp As System.Text.StringBuilder
        Dim SendBuf As System.Text.StringBuilder

        'Set Equipment ID, delimiter and EOI
        If funcSetParam() = False Then Exit Sub
        'Get data to be sent from edit box
        SendBuf = New System.Text.StringBuilder(txtSend.Text)
        SendLen = Len(txtSend.Text)
        If SendLen = 0 Then
            strTmp = New System.Text.StringBuilder("GpibSendData : there is no data")
            funcSetlstRet(strTmp.ToString)
            Exit Sub
        End If

        funcSetlstRet("GpibSendData : sending data...")
        'Send data
        mlngRet = GpibSendData(mintDevId, SendLen, SendBuf)
        If mlngRet <> 0 Then
            'Error
            strTmp = New System.Text.StringBuilder("", 256)
            Call GpibGetErrorString(mlngRet, strTmp)
            Call funcSetlstRet(strTmp.ToString)
        Else
            'When sent data normally
            strTmp = New System.Text.StringBuilder("GpibSendData : the number of sent data = " & SendLen)
            Call funcSetlstRet(strTmp.ToString)
            strTmp = New System.Text.StringBuilder("[Send data] completed normally")
            Call funcSetlstRet(strTmp.ToString)
        End If
    End Sub

    '**************************************************************************************************
    '   Receive data
    '   Function: Receive data from master device
    '**************************************************************************************************
    Private Sub cmdRec_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdRec.Click
        Dim RecLen As Integer
        Dim strTmp As System.Text.StringBuilder
        Dim RecBuf As System.Text.StringBuilder


        'Set Equipment ID, delimiter and EOI
        If funcSetParam() = False Then Exit Sub

        RecBuf = New System.Text.StringBuilder("", 256)
        RecLen = 256 'Set recieving buffer size
        Call funcSetlstRet("GpibRecData : receiving data...") 'Display in list
        'Receive data
        mlngRet = GpibRecData(mintDevId, RecLen, RecBuf)
        RecBuf.Length = RecLen
        If mlngRet <> 0 Then
            'Error
            strTmp = New System.Text.StringBuilder("", 256)
            Call GpibGetErrorString(mlngRet, strTmp)
            Call funcSetlstRet(strTmp.ToString) 'Display in list
        Else
            'When received data normally
            txtRec.Text = VB.Left(RecBuf.ToString, RecLen)
            strTmp = New System.Text.StringBuilder("GpibRecData : the number of received data = " & RecLen)
            Call funcSetlstRet(strTmp.ToString) 'Display in list
            strTmp = New System.Text.StringBuilder("[Receive data] completed normally")
            Call funcSetlstRet(strTmp.ToString) 'Display in list
        End If
    End Sub

    '**************************************************************************************************
    '   Set status byte
    '   Function: Transmit SRQ and set status byte
    '**************************************************************************************************
    Private Sub cmdSendSrq_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdSendSrq.Click
        Dim strTmp As System.Text.StringBuilder
        Dim intSrqSend As Short

        'Get setting value of SRQ
        If optSrqNotSend.Checked = True Then
            intSrqSend = 0
        Else
            intSrqSend = 1
        End If
        'Transmit SRQ and perform the functin of seting status byte
        mlngRet = GpibSendSRQ(mintDevId, intSrqSend, Val(txtSPollStb.Text))
        'Process return value
        If mlngRet <> 0 Then
            strTmp = New System.Text.StringBuilder("", 256)
            Call GpibGetErrorString(mlngRet, strTmp)
            Call funcSetlstRet(strTmp.ToString)
        Else
            'Display
            strTmp = New System.Text.StringBuilder("[Transmit SRQ and set status byte] completed normally")
            Call funcSetlstRet(strTmp.ToString)
        End If
    End Sub

    '**************************************************************************************************
    '   Set parallel poll response
    '**************************************************************************************************
    Private Sub cmdParallelpollSetting_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdParallelpollSetting.Click

        Dim Response As Short
        Dim Ist As Short
        Dim strTmp As System.Text.StringBuilder


        If optPPollResponseNot.Checked = True Then
            '[No response]
            Response = 0
        ElseIf optPPollResponseIst0.Checked = True Then
            '[Response of ISTbitiIST=0j]
            Response = 1
            Ist = 0
        ElseIf optPPollResponseIst1.Checked = True Then
            '[Response of ISTbitiIST=1j]
            Response = 1
            Ist = 1
        ElseIf optPPollResponseSrq.Checked = True Then
            '[Response with SRQ]
            Response = 2
        End If

        'Perform the function of setting parallel poll response
        mlngRet = GpibSetPPollResponse(mintDevId, Response)
        If mlngRet <> 0 Then
            'Error
            strTmp = New System.Text.StringBuilder("", 256)
            Call GpibGetErrorString(mlngRet, strTmp)
            Call funcSetlstRet(strTmp.ToString)
        Else
            strTmp = New System.Text.StringBuilder("[Set parallel poll response] completed normally")
            Call funcSetlstRet(strTmp.ToString)
        End If

        If Response = 1 Then
            ' Perform the function of setting ISTbit
            mlngRet = GpibSetIst(mintDevId, Ist)
            If mlngRet <> 0 Then
                'Error
                strTmp = New System.Text.StringBuilder("", 256)
                Call GpibGetErrorString(mlngRet, strTmp)
                Call funcSetlstRet(strTmp.ToString)
            Else
                strTmp = New System.Text.StringBuilder("[Set IST of parallel poll response] completed normally")
                Call funcSetlstRet(strTmp.ToString)
            End If
        End If

    End Sub

    '**************************************************************************************************
    '   Clear send/receive text data
    '**************************************************************************************************
    Private Sub cmdDataDel_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdDataDel.Click
        txtSend.Text = ""
        txtRec.Text = ""
    End Sub

    '**************************************************************************************************
    '   Clear return code
    '**************************************************************************************************
    Private Sub cmdRetDel_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdRetDel.Click
        lstRet.Items.Clear()
    End Sub

    '**************************************************************************************************
    '   Input rule(only number)
    '**************************************************************************************************
    Private Sub txtSPollStb_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtSPollStb.KeyPress
        Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
        If (KeyAscii < Asc("0") Or KeyAscii > Asc("9")) And KeyAscii <> System.Windows.Forms.Keys.Back Then
            KeyAscii = 0
        End If
        If KeyAscii = 0 Then
            eventArgs.Handled = True
        End If
    End Sub
End Class

