Option Strict Off
Option Explicit On 

Public Class ConRec
    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 Frame6 As System.Windows.Forms.GroupBox
    Public WithEvents txtTimerInterval As System.Windows.Forms.TextBox
    Public WithEvents cmdSrqRecTrigger As System.Windows.Forms.Button
    Public WithEvents optTimer As System.Windows.Forms.RadioButton
    Public WithEvents optMaxSpeed As System.Windows.Forms.RadioButton
    Public WithEvents optManual As System.Windows.Forms.RadioButton
    Public WithEvents lblTimerUnit As System.Windows.Forms.Label
    Public WithEvents Frame5 As System.Windows.Forms.GroupBox
    Public WithEvents cmdSaveCsv As System.Windows.Forms.Button
    Public WithEvents cmdEventRecStop As System.Windows.Forms.Button
    Public WithEvents cmdEventRecStart As System.Windows.Forms.Button
    Public WithEvents lstEventRec As System.Windows.Forms.ListBox
    Public WithEvents Frame4 As System.Windows.Forms.GroupBox
    Public WithEvents cmdRec As System.Windows.Forms.Button
    Public WithEvents txtRec As System.Windows.Forms.TextBox
    Public WithEvents cmdSend As System.Windows.Forms.Button
    Public WithEvents txtSend As System.Windows.Forms.TextBox
    Public WithEvents cmdExit As System.Windows.Forms.Button
    Public WithEvents cmdDataDel As System.Windows.Forms.Button
    Public WithEvents cmdInit As System.Windows.Forms.Button
    Public WithEvents Frame1 As System.Windows.Forms.GroupBox
    Public WithEvents txtMyAddr As System.Windows.Forms.TextBox
    Public WithEvents txtDevName As System.Windows.Forms.TextBox
    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 lstRet As System.Windows.Forms.ListBox
    Public WithEvents cmdRetDel As System.Windows.Forms.Button
    Public WithEvents tmrTimerEventRec As System.Windows.Forms.Timer
    Public WithEvents Frame3 As System.Windows.Forms.GroupBox
    Public WithEvents txtAddr As System.Windows.Forms.TextBox
    Public WithEvents cmdSearch As System.Windows.Forms.Button
    Public WithEvents cboEoi As System.Windows.Forms.ComboBox
    Public WithEvents cboDelim As System.Windows.Forms.ComboBox
    Public WithEvents cboAddr As System.Windows.Forms.ComboBox
    Public WithEvents Label5 As System.Windows.Forms.Label
    Public WithEvents Label4 As System.Windows.Forms.Label
    Public WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents sfdSaveCsv As System.Windows.Forms.SaveFileDialog
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container()
        Me.Frame6 = New System.Windows.Forms.GroupBox()
        Me.txtTimerInterval = New System.Windows.Forms.TextBox()
        Me.cmdSrqRecTrigger = New System.Windows.Forms.Button()
        Me.optTimer = New System.Windows.Forms.RadioButton()
        Me.optMaxSpeed = New System.Windows.Forms.RadioButton()
        Me.optManual = New System.Windows.Forms.RadioButton()
        Me.lblTimerUnit = New System.Windows.Forms.Label()
        Me.Frame5 = New System.Windows.Forms.GroupBox()
        Me.cmdSaveCsv = New System.Windows.Forms.Button()
        Me.cmdEventRecStop = New System.Windows.Forms.Button()
        Me.cmdEventRecStart = New System.Windows.Forms.Button()
        Me.lstEventRec = New System.Windows.Forms.ListBox()
        Me.Frame4 = New System.Windows.Forms.GroupBox()
        Me.cmdRec = New System.Windows.Forms.Button()
        Me.txtRec = New System.Windows.Forms.TextBox()
        Me.cmdSend = New System.Windows.Forms.Button()
        Me.txtSend = New System.Windows.Forms.TextBox()
        Me.cmdExit = New System.Windows.Forms.Button()
        Me.cmdDataDel = New System.Windows.Forms.Button()
        Me.cmdInit = New System.Windows.Forms.Button()
        Me.Frame1 = New System.Windows.Forms.GroupBox()
        Me.txtMyAddr = New System.Windows.Forms.TextBox()
        Me.txtDevName = New System.Windows.Forms.TextBox()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.Frame2 = New System.Windows.Forms.GroupBox()
        Me.lstRet = New System.Windows.Forms.ListBox()
        Me.cmdRetDel = New System.Windows.Forms.Button()
        Me.tmrTimerEventRec = New System.Windows.Forms.Timer(Me.components)
        Me.Frame3 = New System.Windows.Forms.GroupBox()
        Me.txtAddr = New System.Windows.Forms.TextBox()
        Me.cmdSearch = New System.Windows.Forms.Button()
        Me.cboEoi = New System.Windows.Forms.ComboBox()
        Me.cboDelim = New System.Windows.Forms.ComboBox()
        Me.cboAddr = New System.Windows.Forms.ComboBox()
        Me.Label5 = New System.Windows.Forms.Label()
        Me.Label4 = New System.Windows.Forms.Label()
        Me.Label3 = New System.Windows.Forms.Label()
        Me.sfdSaveCsv = New System.Windows.Forms.SaveFileDialog()
        Me.Frame6.SuspendLayout()
        Me.Frame5.SuspendLayout()
        Me.Frame4.SuspendLayout()
        Me.Frame1.SuspendLayout()
        Me.Frame2.SuspendLayout()
        Me.Frame3.SuspendLayout()
        Me.SuspendLayout()
        '
        'Frame6
        '
        Me.Frame6.BackColor = System.Drawing.SystemColors.Control
        Me.Frame6.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtTimerInterval, Me.cmdSrqRecTrigger, Me.optTimer, Me.optMaxSpeed, Me.optManual, Me.lblTimerUnit})
        Me.Frame6.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Frame6.Location = New System.Drawing.Point(495, 266)
        Me.Frame6.Name = "Frame6"
        Me.Frame6.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Frame6.Size = New System.Drawing.Size(192, 144)
        Me.Frame6.TabIndex = 54
        Me.Frame6.TabStop = False
        Me.Frame6.Text = "Start timing set"
        '
        'txtTimerInterval
        '
        Me.txtTimerInterval.AcceptsReturn = True
        Me.txtTimerInterval.AutoSize = False
        Me.txtTimerInterval.BackColor = System.Drawing.SystemColors.Window
        Me.txtTimerInterval.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.txtTimerInterval.ForeColor = System.Drawing.SystemColors.WindowText
        Me.txtTimerInterval.ImeMode = System.Windows.Forms.ImeMode.Disable
        Me.txtTimerInterval.Location = New System.Drawing.Point(72, 61)
        Me.txtTimerInterval.MaxLength = 5
        Me.txtTimerInterval.Name = "txtTimerInterval"
        Me.txtTimerInterval.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.txtTimerInterval.Size = New System.Drawing.Size(64, 25)
        Me.txtTimerInterval.TabIndex = 19
        Me.txtTimerInterval.Text = ""
        '
        'cmdSrqRecTrigger
        '
        Me.cmdSrqRecTrigger.BackColor = System.Drawing.SystemColors.Control
        Me.cmdSrqRecTrigger.Cursor = System.Windows.Forms.Cursors.Default
        Me.cmdSrqRecTrigger.ForeColor = System.Drawing.SystemColors.ControlText
        Me.cmdSrqRecTrigger.Location = New System.Drawing.Point(88, 24)
        Me.cmdSrqRecTrigger.Name = "cmdSrqRecTrigger"
        Me.cmdSrqRecTrigger.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdSrqRecTrigger.Size = New System.Drawing.Size(96, 27)
        Me.cmdSrqRecTrigger.TabIndex = 18
        Me.cmdSrqRecTrigger.Text = "Trigger"
        '
        'optTimer
        '
        Me.optTimer.BackColor = System.Drawing.SystemColors.Control
        Me.optTimer.Cursor = System.Windows.Forms.Cursors.Default
        Me.optTimer.ForeColor = System.Drawing.SystemColors.ControlText
        Me.optTimer.Location = New System.Drawing.Point(8, 63)
        Me.optTimer.Name = "optTimer"
        Me.optTimer.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.optTimer.Size = New System.Drawing.Size(65, 20)
        Me.optTimer.TabIndex = 21
        Me.optTimer.TabStop = True
        Me.optTimer.Text = "Timer"
        '
        'optMaxSpeed
        '
        Me.optMaxSpeed.BackColor = System.Drawing.SystemColors.Control
        Me.optMaxSpeed.Cursor = System.Windows.Forms.Cursors.Default
        Me.optMaxSpeed.ForeColor = System.Drawing.SystemColors.ControlText
        Me.optMaxSpeed.Location = New System.Drawing.Point(8, 103)
        Me.optMaxSpeed.Name = "optMaxSpeed"
        Me.optMaxSpeed.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.optMaxSpeed.Size = New System.Drawing.Size(128, 20)
        Me.optMaxSpeed.TabIndex = 22
        Me.optMaxSpeed.TabStop = True
        Me.optMaxSpeed.Text = "Maximum speed"
        '
        'optManual
        '
        Me.optManual.BackColor = System.Drawing.SystemColors.Control
        Me.optManual.Checked = True
        Me.optManual.Cursor = System.Windows.Forms.Cursors.Default
        Me.optManual.ForeColor = System.Drawing.SystemColors.ControlText
        Me.optManual.Location = New System.Drawing.Point(8, 30)
        Me.optManual.Name = "optManual"
        Me.optManual.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.optManual.Size = New System.Drawing.Size(81, 17)
        Me.optManual.TabIndex = 20
        Me.optManual.TabStop = True
        Me.optManual.Text = "Manual"
        '
        'lblTimerUnit
        '
        Me.lblTimerUnit.AutoSize = True
        Me.lblTimerUnit.BackColor = System.Drawing.SystemColors.Control
        Me.lblTimerUnit.Cursor = System.Windows.Forms.Cursors.Default
        Me.lblTimerUnit.ForeColor = System.Drawing.SystemColors.ControlText
        Me.lblTimerUnit.Location = New System.Drawing.Point(144, 66)
        Me.lblTimerUnit.Name = "lblTimerUnit"
        Me.lblTimerUnit.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.lblTimerUnit.Size = New System.Drawing.Size(39, 15)
        Me.lblTimerUnit.TabIndex = 32
        Me.lblTimerUnit.Text = "mSec"
        '
        'Frame5
        '
        Me.Frame5.BackColor = System.Drawing.SystemColors.Control
        Me.Frame5.Controls.AddRange(New System.Windows.Forms.Control() {Me.cmdSaveCsv, Me.cmdEventRecStop, Me.cmdEventRecStart, Me.lstEventRec})
        Me.Frame5.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Frame5.Location = New System.Drawing.Point(9, 266)
        Me.Frame5.Name = "Frame5"
        Me.Frame5.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Frame5.Size = New System.Drawing.Size(479, 144)
        Me.Frame5.TabIndex = 53
        Me.Frame5.TabStop = False
        Me.Frame5.Text = "Receive data of SRQ event"
        '
        'cmdSaveCsv
        '
        Me.cmdSaveCsv.BackColor = System.Drawing.SystemColors.Control
        Me.cmdSaveCsv.Cursor = System.Windows.Forms.Cursors.Default
        Me.cmdSaveCsv.ForeColor = System.Drawing.SystemColors.ControlText
        Me.cmdSaveCsv.Location = New System.Drawing.Point(327, 94)
        Me.cmdSaveCsv.Name = "cmdSaveCsv"
        Me.cmdSaveCsv.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdSaveCsv.Size = New System.Drawing.Size(144, 39)
        Me.cmdSaveCsv.TabIndex = 17
        Me.cmdSaveCsv.Text = "Save received data"
        '
        'cmdEventRecStop
        '
        Me.cmdEventRecStop.BackColor = System.Drawing.SystemColors.Control
        Me.cmdEventRecStop.Cursor = System.Windows.Forms.Cursors.Default
        Me.cmdEventRecStop.Enabled = False
        Me.cmdEventRecStop.ForeColor = System.Drawing.SystemColors.ControlText
        Me.cmdEventRecStop.Location = New System.Drawing.Point(327, 59)
        Me.cmdEventRecStop.Name = "cmdEventRecStop"
        Me.cmdEventRecStop.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdEventRecStop.Size = New System.Drawing.Size(144, 27)
        Me.cmdEventRecStop.TabIndex = 16
        Me.cmdEventRecStop.Text = "Stop receiving SRQ"
        '
        'cmdEventRecStart
        '
        Me.cmdEventRecStart.BackColor = System.Drawing.SystemColors.Control
        Me.cmdEventRecStart.Cursor = System.Windows.Forms.Cursors.Default
        Me.cmdEventRecStart.ForeColor = System.Drawing.SystemColors.ControlText
        Me.cmdEventRecStart.Location = New System.Drawing.Point(327, 24)
        Me.cmdEventRecStart.Name = "cmdEventRecStart"
        Me.cmdEventRecStart.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdEventRecStart.Size = New System.Drawing.Size(144, 27)
        Me.cmdEventRecStart.TabIndex = 15
        Me.cmdEventRecStart.Text = "Start receiving SRQ"
        '
        'lstEventRec
        '
        Me.lstEventRec.BackColor = System.Drawing.SystemColors.Window
        Me.lstEventRec.Cursor = System.Windows.Forms.Cursors.Default
        Me.lstEventRec.ForeColor = System.Drawing.SystemColors.WindowText
        Me.lstEventRec.ItemHeight = 16
        Me.lstEventRec.Location = New System.Drawing.Point(8, 24)
        Me.lstEventRec.Name = "lstEventRec"
        Me.lstEventRec.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.lstEventRec.Size = New System.Drawing.Size(312, 116)
        Me.lstEventRec.TabIndex = 18
        '
        'Frame4
        '
        Me.Frame4.BackColor = System.Drawing.SystemColors.Control
        Me.Frame4.Controls.AddRange(New System.Windows.Forms.Control() {Me.cmdRec, Me.txtRec, Me.cmdSend, Me.txtSend})
        Me.Frame4.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Frame4.Location = New System.Drawing.Point(9, 168)
        Me.Frame4.Name = "Frame4"
        Me.Frame4.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Frame4.Size = New System.Drawing.Size(553, 94)
        Me.Frame4.TabIndex = 52
        Me.Frame4.TabStop = False
        Me.Frame4.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(432, 56)
        Me.cmdRec.Name = "cmdRec"
        Me.cmdRec.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdRec.Size = New System.Drawing.Size(113, 29)
        Me.cmdRec.TabIndex = 10
        Me.cmdRec.Text = "Receive"
        '
        '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(417, 29)
        Me.txtRec.TabIndex = 12
        Me.txtRec.Text = ""
        '
        '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(432, 19)
        Me.cmdSend.Name = "cmdSend"
        Me.cmdSend.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdSend.Size = New System.Drawing.Size(113, 29)
        Me.cmdSend.TabIndex = 9
        Me.cmdSend.Text = "Send"
        '
        '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(417, 29)
        Me.txtSend.TabIndex = 11
        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, 43)
        Me.cmdExit.Name = "cmdExit"
        Me.cmdExit.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdExit.Size = New System.Drawing.Size(113, 25)
        Me.cmdExit.TabIndex = 1
        Me.cmdExit.Text = "Exit"
        '
        '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(566, 188)
        Me.cmdDataDel.Name = "cmdDataDel"
        Me.cmdDataDel.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdDataDel.Size = New System.Drawing.Size(113, 27)
        Me.cmdDataDel.TabIndex = 13
        Me.cmdDataDel.Text = "Clear data"
        '
        '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, 11)
        Me.cmdInit.Name = "cmdInit"
        Me.cmdInit.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdInit.Size = New System.Drawing.Size(113, 25)
        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.txtMyAddr, Me.txtDevName, Me.Label2, Me.Label1})
        Me.Frame1.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Frame1.Location = New System.Drawing.Point(9, 8)
        Me.Frame1.Name = "Frame1"
        Me.Frame1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Frame1.Size = New System.Drawing.Size(423, 57)
        Me.Frame1.TabIndex = 47
        Me.Frame1.TabStop = False
        Me.Frame1.Text = "Self information"
        '
        '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.ForeColor = System.Drawing.SystemColors.WindowText
        Me.txtMyAddr.Location = New System.Drawing.Point(336, 22)
        Me.txtMyAddr.MaxLength = 0
        Me.txtMyAddr.Name = "txtMyAddr"
        Me.txtMyAddr.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.txtMyAddr.Size = New System.Drawing.Size(72, 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, 22)
        Me.txtDevName.MaxLength = 0
        Me.txtDevName.Name = "txtDevName"
        Me.txtDevName.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.txtDevName.Size = New System.Drawing.Size(88, 25)
        Me.txtDevName.TabIndex = 2
        Me.txtDevName.Text = ""
        '
        '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(224, 24)
        Me.Label2.Name = "Label2"
        Me.Label2.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label2.Size = New System.Drawing.Size(104, 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, 24)
        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="
        '
        'Frame2
        '
        Me.Frame2.BackColor = System.Drawing.SystemColors.Control
        Me.Frame2.Controls.AddRange(New System.Windows.Forms.Control() {Me.lstRet})
        Me.Frame2.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Frame2.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Frame2.Location = New System.Drawing.Point(9, 414)
        Me.Frame2.Name = "Frame2"
        Me.Frame2.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Frame2.Size = New System.Drawing.Size(535, 95)
        Me.Frame2.TabIndex = 50
        Me.Frame2.TabStop = False
        Me.Frame2.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(520, 68)
        Me.lstRet.TabIndex = 35
        '
        'cmdRetDel
        '
        Me.cmdRetDel.BackColor = System.Drawing.SystemColors.Control
        Me.cmdRetDel.Cursor = System.Windows.Forms.Cursors.Default
        Me.cmdRetDel.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdRetDel.ForeColor = System.Drawing.SystemColors.ControlText
        Me.cmdRetDel.Location = New System.Drawing.Point(558, 448)
        Me.cmdRetDel.Name = "cmdRetDel"
        Me.cmdRetDel.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdRetDel.Size = New System.Drawing.Size(127, 27)
        Me.cmdRetDel.TabIndex = 14
        Me.cmdRetDel.Text = "Clear return code"
        '
        'tmrTimerEventRec
        '
        Me.tmrTimerEventRec.Interval = 1
        '
        'Frame3
        '
        Me.Frame3.BackColor = System.Drawing.SystemColors.Control
        Me.Frame3.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtAddr, Me.cmdSearch, Me.cboEoi, Me.cboDelim, Me.cboAddr, Me.Label5, Me.Label4, Me.Label3})
        Me.Frame3.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Frame3.Location = New System.Drawing.Point(9, 69)
        Me.Frame3.Name = "Frame3"
        Me.Frame3.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Frame3.Size = New System.Drawing.Size(553, 95)
        Me.Frame3.TabIndex = 51
        Me.Frame3.TabStop = False
        Me.Frame3.Text = "Target information"
        '
        'txtAddr
        '
        Me.txtAddr.AcceptsReturn = True
        Me.txtAddr.AutoSize = False
        Me.txtAddr.BackColor = System.Drawing.SystemColors.Window
        Me.txtAddr.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.txtAddr.ForeColor = System.Drawing.SystemColors.WindowText
        Me.txtAddr.Location = New System.Drawing.Point(120, 28)
        Me.txtAddr.MaxLength = 0
        Me.txtAddr.Name = "txtAddr"
        Me.txtAddr.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.txtAddr.Size = New System.Drawing.Size(73, 21)
        Me.txtAddr.TabIndex = 5
        Me.txtAddr.Text = "Text1"
        '
        'cmdSearch
        '
        Me.cmdSearch.BackColor = System.Drawing.SystemColors.Control
        Me.cmdSearch.Cursor = System.Windows.Forms.Cursors.Default
        Me.cmdSearch.ForeColor = System.Drawing.SystemColors.ControlText
        Me.cmdSearch.Location = New System.Drawing.Point(432, 59)
        Me.cmdSearch.Name = "cmdSearch"
        Me.cmdSearch.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cmdSearch.Size = New System.Drawing.Size(113, 29)
        Me.cmdSearch.TabIndex = 4
        Me.cmdSearch.Text = "Find listener"
        '
        '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(288, 62)
        Me.cboEoi.Name = "cboEoi"
        Me.cboEoi.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cboEoi.Size = New System.Drawing.Size(88, 24)
        Me.cboEoi.TabIndex = 8
        '
        '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(120, 62)
        Me.cboDelim.Name = "cboDelim"
        Me.cboDelim.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cboDelim.Size = New System.Drawing.Size(96, 24)
        Me.cboDelim.TabIndex = 7
        '
        'cboAddr
        '
        Me.cboAddr.BackColor = System.Drawing.SystemColors.Window
        Me.cboAddr.Cursor = System.Windows.Forms.Cursors.Default
        Me.cboAddr.ForeColor = System.Drawing.SystemColors.WindowText
        Me.cboAddr.Location = New System.Drawing.Point(233, 27)
        Me.cboAddr.Name = "cboAddr"
        Me.cboAddr.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.cboAddr.Size = New System.Drawing.Size(312, 24)
        Me.cboAddr.TabIndex = 6
        '
        '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, 29)
        Me.Label5.Name = "Label5"
        Me.Label5.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label5.Size = New System.Drawing.Size(112, 19)
        Me.Label5.TabIndex = 11
        Me.Label5.Text = "Target address ="
        '
        '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(233, 63)
        Me.Label4.Name = "Label4"
        Me.Label4.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label4.Size = New System.Drawing.Size(49, 20)
        Me.Label4.TabIndex = 10
        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, 63)
        Me.Label3.Name = "Label3"
        Me.Label3.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label3.Size = New System.Drawing.Size(81, 20)
        Me.Label3.TabIndex = 9
        Me.Label3.Text = "Delimiter ="
        '
        'sfdSaveCsv
        '
        Me.sfdSaveCsv.FileName = "doc1"
        '
        'ConRec
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15)
        Me.ClientSize = New System.Drawing.Size(698, 518)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Frame5, Me.Frame4, Me.cmdExit, Me.cmdDataDel, Me.cmdInit, Me.Frame1, Me.Frame2, Me.cmdRetDel, Me.Frame3, Me.Frame6})
        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 = "ConRec"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "ConRec"
        Me.Frame6.ResumeLayout(False)
        Me.Frame5.ResumeLayout(False)
        Me.Frame4.ResumeLayout(False)
        Me.Frame1.ResumeLayout(False)
        Me.Frame2.ResumeLayout(False)
        Me.Frame3.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private mlngRet As Integer
    Private mintDevId As Short
    Private mintEqpId(32) As Short
    Private mintSelectEqpId As Short
    Private mintAddrArray(32) As Short

    Public Const GPIB_NOTIFY_MESSAGE As Long = &H15FFS          'Message

    '**************************************************************************************************
    '   Set initial value
    '**************************************************************************************************
    Private Sub ConRec_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
        txtTimerInterval.Text = CStr(1000) '1000mSec
        txtAddr.Text = CStr(0)
        txtSend.Text = "CONTEC ConRec Sample"
    End Sub

    '**************************************************************************************************
    '   Ending process(force to end)
    '**************************************************************************************************
    Private Sub ConRec_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 'Xg{bNX̌Eݒ
                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

    '**************************************************************************************************
    '   Display transmitted string to list box of "Return code"(sub routine)
    '   Return value: TRUE(normally), FALSE(abnormally)
    '**************************************************************************************************
    Private Function funcSetlstSrqRecData(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 lstEventRec.Items.Count >= 256 Then 'Set the maximum number of list box
                lstEventRec.Items.RemoveAt(0)
                lstEventRec.Items.Add(strRet)
            Else
                lstEventRec.Items.Add(strRet)
            End If
            lstEventRec.SelectedIndex = lstEventRec.Items.Count - 1
        End If
        funcSetlstSrqRecData = 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

        'Specify the partner apparatus being detected
        If cboAddr.Items.Count <> 0 Then
            'Get Equipment ID of the device specified in combo box
            mintSelectEqpId = mintEqpId(cboAddr.SelectedIndex)
        Else
            'Get Equipment ID of device address specified in edit box
            Delim = cboDelim.SelectedIndex
            mlngRet = GpibSetEquipment(mintDevId, mintSelectEqpId, Val(txtAddr.Text), 0, Delim)
            If mlngRet <> 0 Then
                'Error
                strTmp = New System.Text.StringBuilder("", 256)
                Call GpibGetErrorString(mlngRet, strTmp)
                Call funcSetlstRet(strTmp.ToString)
                funcSetParam = True
                Exit Function
            End If
        End If

        'Set delimiter code and EOI line
        Delim = cboDelim.SelectedIndex
        Eoi = cboEoi.SelectedIndex
        Eos = 0
        mlngRet = GpibSetDelim(mintSelectEqpId, Delim, Eoi, Eos)
        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("[Partner apparatus setting] completed normally")
            Call funcSetlstRet(strTmp.ToString)
        End If

        funcSetParam = False
    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 device address
            mlngRet = GpibGetStatus(mintDevId, &H8S, lngData)
            If mlngRet = 0 Then txtMyAddr.Text = CStr(lngData)
            'Confirm whether it is set to master in property page
            mlngRet = GpibGetStatus(mintDevId, &HAS, lngData)
            'Confirm whether it is set to master
            If (mlngRet = 0) And (lngData = 1) Then Call MsgBox("It is not a master. Please set it to master in property page.", MsgBoxStyle.OKOnly)
            '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

    '**************************************************************************************************
    '   Detect partner apparatus
    '   FuntionF Detect partner apparatus from Device ID and get Equipment ID.
    '         Send the [*IDN?] command according with IEEE488.2 standard to partner apparatus with
    '         the Equipment ID and get Device ID(maker and module number etc.).
    '**************************************************************************************************
    Private Sub cmdSearch_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdSearch.Click
        Dim strTmp As System.Text.StringBuilder
        Dim intPrmAddr As Short
        Dim intScdAddr As Short
        Dim intArraySize As Short
        Dim intArrayCount As Short
        Dim lngSendLen As Integer
        Dim strSendBuf As System.Text.StringBuilder
        Dim lngRecLen As Integer
        Dim strRecBuf As System.Text.StringBuilder
        Dim EqpInforBuf As String = ""

        intPrmAddr = -1 'Search all primary address
        intScdAddr = 0 'Do not search secondary address 
        intArraySize = 32 'Specify array size
        'Perform the function of detecting partner apparatus
        mlngRet = GpibFindListener(mintDevId, intPrmAddr, intScdAddr, intArraySize, mintAddrArray)
        'Process return value
        If mlngRet <> 0 Then
            strTmp = New System.Text.StringBuilder("", 256)
            Call GpibGetErrorString(mlngRet, strTmp)
            Call funcSetlstRet(strTmp.ToString)
            Exit Sub
        End If
        'Display
        strTmp = New System.Text.StringBuilder("GpibFindListener : the number of detected partner apparatus(es) = " & intArraySize)
        Call funcSetlstRet(strTmp.ToString)
        'Initialize combo box items
        cboAddr.Items.Clear()
        For intArrayCount = 0 To intArraySize - 1
            'Perform the function of getting Equipment ID
            mlngRet = GpibSetEquipment(mintDevId, mintEqpId(intArrayCount), mintAddrArray(intArrayCount), 0, cboDelim.SelectedIndex)
            'Process return value
            If mlngRet <> 0 Then
                strTmp = New System.Text.StringBuilder("", 256)
                Call GpibGetErrorString(mlngRet, strTmp)
                Call funcSetlstRet(strTmp.ToString)
            Else
                '---------------------------------------
                'Inquiry device information(data sending)
                '---------------------------------------
                strSendBuf = New System.Text.StringBuilder("*IDN?")
                lngSendLen = strSendBuf.Length
                mlngRet = GpibSendData(mintEqpId(intArrayCount), lngSendLen, strSendBuf)
                'Process return value
                If mlngRet <> 0 Then
                    strTmp = New System.Text.StringBuilder("", 256)
                    Call GpibGetErrorString(mlngRet, strTmp)
                    Call funcSetlstRet(strTmp.ToString)
                Else
                    '---------------------------------------
                    'Inquiry device information(data receiving)
                    '---------------------------------------
                    strRecBuf = New System.Text.StringBuilder("", 256)
                    lngRecLen = 256 'Specify buffer size for receiving data
                    mlngRet = GpibRecData(mintEqpId(intArrayCount), lngRecLen, strRecBuf)
                    strRecBuf.Length = lngRecLen
                    'Process return value
                    If mlngRet <> 0 Then
                        strTmp = New System.Text.StringBuilder("", 256)
                        Call GpibGetErrorString(mlngRet, strTmp)
                        Call funcSetlstRet(strTmp.ToString)
                    Else
                        '---------------------------------------
                        'Confirm whether receiving data accords with IEEE488.2 standard
                        '---------------------------------------
                        If InStr(1, strRecBuf.ToString, ",", CompareMethod.Text) > 0 Then
                            'Combine with address information
                            EqpInforBuf = "Address:" & mintAddrArray(intArrayCount) & strRecBuf.ToString
                        Else
                            'Include only address information if receiving data does not accord with IEEE488.2 standard
                            EqpInforBuf = "Address:" & mintAddrArray(intArrayCount)
                        End If
                    End If
                    'Add to the list
                    cboAddr.Items.Insert(intArrayCount, EqpInforBuf)
                    cboAddr.SelectedIndex = intArrayCount
                End If
            End If
        Next intArrayCount
        'Display
        strTmp = New System.Text.StringBuilder("[Partner apparatus setting] completed normally")
        Call funcSetlstRet(strTmp.ToString)
        If cboAddr.SelectedIndex <> -1 Then
            txtAddr.Text = CStr(Val(CStr(mintAddrArray(cboAddr.SelectedIndex))))
        End If

    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 strTmp As System.Text.StringBuilder
        Dim lngSendLen As Integer
        Dim strSendBuf As System.Text.StringBuilder
        'Set partner apparatus
        If funcSetParam() = True Then Exit Sub

        strSendBuf = New System.Text.StringBuilder(txtSend.Text)
        lngSendLen = strSendBuf.Length
        If lngSendLen = 0 Then
            strTmp = New System.Text.StringBuilder("GpibSendData : there is no data")
            Call funcSetlstRet(strTmp.ToString)
            Exit Sub
        End If
        strTmp = New System.Text.StringBuilder("GpibSendData : sending data....")
        Call funcSetlstRet(strTmp.ToString)
        'Send data
        mlngRet = GpibSendData(mintSelectEqpId, lngSendLen, strSendBuf)
        '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("GpibSendData : the number of sent data = " & lngSendLen)
            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 slave device
    '**************************************************************************************************
    Private Sub cmdRec_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdRec.Click
        Dim strTmp As System.Text.StringBuilder
        Dim lngRecLen As Integer
        Dim strRecBuf As System.Text.StringBuilder
        'Set partner apparatus
        If funcSetParam() = True Then Exit Sub
        strTmp = New System.Text.StringBuilder("GpibRecData : receiving data...")
        Call funcSetlstRet(strTmp.ToString)
        strRecBuf = New System.Text.StringBuilder("", 256)
        lngRecLen = 256
        'Receive data
        mlngRet = GpibRecData(mintSelectEqpId, lngRecLen, strRecBuf)
        strRecBuf.Length = lngRecLen
        'Process return value
        If mlngRet <> 0 Then
            strTmp = New System.Text.StringBuilder("", 256)
            Call GpibGetErrorString(mlngRet, strTmp)
            Call funcSetlstRet(strTmp.ToString)
        Else
            'Display
            strRecBuf.Length = lngRecLen
            txtRec.Text = strRecBuf.ToString  'Display received data
            strTmp = New System.Text.StringBuilder("GpibRecData : the number of received data = " & lngRecLen)
            Call funcSetlstRet(strTmp.ToString)
            strTmp = New System.Text.StringBuilder("[Receive data] completed normally")
            Call funcSetlstRet(strTmp.ToString)
        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 = ""
        lstEventRec.Items.Clear()
    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

    '**************************************************************************************************
    '   Start manual timing
    '   Function: Send GET command
    '         When the GET command can not operate normally according to different
    '         partner apparatus,  please modify it according with device specification.
    '**************************************************************************************************
    Private Sub cmdSrqRecTrigger_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdSrqRecTrigger.Click
        Dim strTmp As System.Text.StringBuilder
        'Set partner apparatus
        If funcSetParam() = True Then Exit Sub
        'Perform the function of sending GET command
        mlngRet = GpibSendTrigger(mintSelectEqpId)
        '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("[Send GET command] completed normally")
            Call funcSetlstRet(strTmp.ToString)
        End If
    End Sub

    '**************************************************************************************************
    '   Start SRQ event receiving
    '   Function: Receive data when SRQ is enabled
    '**************************************************************************************************
    Private Sub cmdEventRecStart_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdEventRecStart.Click
        Dim strTmp As System.Text.StringBuilder

        'Start timer if "Timer" is selected
        If optTimer.Checked = True Then
            tmrTimerEventRec.Interval = Val(txtTimerInterval.Text)
            tmrTimerEventRec.Enabled = True
        End If
        'Perform trigger if "Maximum speed" is selected
        If optMaxSpeed.Checked = True Then Call cmdSrqRecTrigger_Click(cmdSrqRecTrigger, New System.EventArgs())
        'Perform the function of event setting(enable SRQ event receiving)
        mlngRet = GpibSetNotifySignal(mintDevId, Handle.ToInt32, &H20S)
        'Process return value
        If mlngRet <> 0 Then
            strTmp = New System.Text.StringBuilder("", 256)
            Call GpibGetErrorString(mlngRet, strTmp)
            Call funcSetlstRet(strTmp.ToString)
        Else
            cmdEventRecStop.Enabled = True
            cmdEventRecStart.Enabled = False
            'Display
            strTmp = New System.Text.StringBuilder("[Start SRQ event receiving] completed normally")
            Call funcSetlstRet(strTmp.ToString)
        End If
    End Sub
    '**************************************************************************************************
    '   Stop SRQ event receiving
    '   Function: Stop event receiving
    '**************************************************************************************************
    Private Sub cmdEventRecStop_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdEventRecStop.Click
        Dim strTmp As System.Text.StringBuilder

        'Stop timer if "timer" is running
        If tmrTimerEventRec.Enabled = True Then tmrTimerEventRec.Enabled = False
        'Perform the function of event setting(cancel SRQ event receiving)
        mlngRet = GpibSetNotifySignal(mintDevId, Handle.ToInt32, 0)
        'Process return value
        If mlngRet <> 0 Then
            strTmp = New System.Text.StringBuilder("", 256)
            Call GpibGetErrorString(mlngRet, strTmp)
            Call funcSetlstRet(strTmp.ToString)
        Else
            cmdEventRecStop.Enabled = False
            cmdEventRecStart.Enabled = True
            'Display
            strTmp = New System.Text.StringBuilder("[Stop SRQ event receiving] completed normally")
            Call funcSetlstRet(strTmp.ToString)
        End If
    End Sub

    '**************************************************************************************************
    '   Save received data to CSV file
    '**************************************************************************************************
    Private Sub cmdSaveCsv_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdSaveCsv.Click
        Dim strFileDataBuf As String
        Dim i As Short

        'Check if there is data in list box
        If lstEventRec.Items.Count = 0 Then
            Call MsgBox("There is no received data.", MsgBoxStyle.OKOnly)
        Else
            sfdSaveCsv.FileName = "ConRec.csv" 'Default file name
            sfdSaveCsv.DefaultExt = "csv"
            'sfdSaveCsv.Title = "Save Received Data"  'Dialog title
            sfdSaveCsv.InitialDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.Location)  'Set the first opend folder to application path
            sfdSaveCsv.OverwritePrompt = True 'Confirm overwrite
            sfdSaveCsv.Filter = "csv files(*.csv)|*.csv|All files (*.*)|*.*"
            On Error GoTo cmdSaveCsvEnd
            'Show dialog
            sfdSaveCsv.ShowDialog()
            FileOpen(1, sfdSaveCsv.FileName, OpenMode.Output, OpenAccess.Write)
            'Write received data to ther file
            strFileDataBuf = "Received Times,Received Data"
            PrintLine(1, Trim(strFileDataBuf))
            For i = 0 To lstEventRec.Items.Count - 1
                strFileDataBuf = i & "," & lstEventRec.Items.Item(i) & vbCrLf
                PrintLine(1, strFileDataBuf)
            Next i
            'Close file
            FileClose(1)
        End If
cmdSaveCsvEnd:
    End Sub

    '**************************************************************************************************
    '   Start timer event
    '   Function: Perform trigger at fixed interval
    '**************************************************************************************************
    Private Sub tmrTimerEventRec_Tick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles tmrTimerEventRec.Tick

        Call cmdSrqRecTrigger_Click(cmdSrqRecTrigger, New System.EventArgs())

    End Sub

    '**************************************************************************************************
    '   SRQ event receiving
    '   Function: Perform serial poll and receive data when SRQ line is enabled
    '**************************************************************************************************
    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        Dim intStb As Short
        Dim strTmp As System.Text.StringBuilder
        Dim intSrqLine As Short
        Dim lngRecLen As Integer
        Dim strRecBuf As System.Text.StringBuilder

        '----------------------------------------
        '   Process of SRQ receiving
        '----------------------------------------
        If (m.Msg = GPIB_NOTIFY_MESSAGE) Then
            If (m.WParam.ToInt32 And &H20S) <> 0 Then
                'Set Equipment ID, delimiter and EOI
                If funcSetParam() = True Then GoTo cmsNotifySignalEventEnd
                strTmp = New System.Text.StringBuilder("GpibSPoll : serial polling...")
                Call funcSetlstRet(strTmp.ToString)
                'Perform serial poll function
                mlngRet = GpibSPoll(mintSelectEqpId, intStb, intSrqLine)
                'Process return value
                If mlngRet <> 0 Then
                    strTmp = New System.Text.StringBuilder("", 256)
                    Call GpibGetErrorString(mlngRet, strTmp)
                    Call funcSetlstRet(strTmp.ToString)
                    Exit Sub
                End If
                strTmp = New System.Text.StringBuilder("GpibSPoll : status byte = " & intStb & " SRQ line = " & intSrqLine)
                Call funcSetlstRet(strTmp.ToString)
                strTmp = New System.Text.StringBuilder("[Serial poll] completed normally")
                Call funcSetlstRet(strTmp.ToString)

                'Receive data
                strRecBuf = New System.Text.StringBuilder("", 256)
                lngRecLen = 256 'Set recieving buffer size
                strTmp = New System.Text.StringBuilder("GpibRecData : receiving data...")
                Call funcSetlstRet(strTmp.ToString)
                'Receive data
                mlngRet = GpibRecData(mintSelectEqpId, lngRecLen, strRecBuf)
                strRecBuf.Length = lngRecLen
                'Process return value
                If mlngRet <> 0 Then
                    strTmp = New System.Text.StringBuilder("", 256)
                    Call GpibGetErrorString(mlngRet, strTmp)
                    Call funcSetlstRet(strTmp.ToString)
                    cmdEventRecStop_Click(cmdEventRecStop, New System.EventArgs())
                    Exit Sub
                End If
                '   Display data
                strRecBuf.Length = lngRecLen
                funcSetlstSrqRecData(strRecBuf.ToString) 'Display received data in list
                strTmp = New System.Text.StringBuilder("GpibRecData : the number of received data = " & lngRecLen)
                funcSetlstRet(strTmp.ToString) 'Display in list
                strTmp = New System.Text.StringBuilder("[Receive Data] completed normally")
                funcSetlstRet(strTmp.ToString) 'Display in list

                'Perform trigger if "Maximum Speed" is selected
                If optMaxSpeed.Checked = True Then Call cmdSrqRecTrigger_Click(cmdSrqRecTrigger, New System.EventArgs())
            End If
cmsNotifySignalEventEnd:
            '----------------------------------------
            '   Setting of waiting next event
            '----------------------------------------
            'Perform the function of event setting
            mlngRet = GpibSetNotifySignal(mintDevId, Handle.ToInt32, &H20S)
            'Process return value
            If mlngRet <> 0 Then
                strTmp = New System.Text.StringBuilder("", 256)
                Call GpibGetErrorString(mlngRet, strTmp)
                Call funcSetlstRet(strTmp.ToString)
            End If
        End If

        MyBase.WndProc(m)
    End Sub

    '**************************************************************************************************
    '   Input rule(only number)
    '**************************************************************************************************
    Private Sub txtTimerInterval_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtTimerInterval.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
