Option Strict Off
Option Explicit On 
Imports System.Runtime.InteropServices
Imports VB = Microsoft.VisualBasic
Friend Class Form1
	Inherits System.Windows.Forms.Form
#Region "Windows tH[ fUCiɂĐꂽR[h"
	Public Sub New()
		MyBase.New()
		If m_vb6FormDefInstance Is Nothing Then
			If m_InitializingDefInstance Then
				m_vb6FormDefInstance = Me
			Else
				Try 
					'X^[gAbv tH[ɂẮAŏɍ쐬ꂽCX^XCX^XɂȂ܂B
					If System.Reflection.Assembly.GetExecutingAssembly.EntryPoint.DeclaringType Is Me.GetType Then
						m_vb6FormDefInstance = Me
					End If
				Catch
				End Try
			End If
		End If
		'̌ĂяóAWindows tH[ fUCiŕKvłB
		InitializeComponent()
	End Sub
	'Form ́AR|[lgꗗɌ㏈s邽߂ dispose I[o[Ch܂B
	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
	'Windows tH[ fUCiŕKvłB
	Private components As System.ComponentModel.IContainer
	Public ToolTip1 As System.Windows.Forms.ToolTip
	Public WithEvents SendRun As System.Windows.Forms.Timer
	Public WithEvents YrAdrBox As System.Windows.Forms.ComboBox
	Public WithEvents Label3 As System.Windows.Forms.Label
	Public WithEvents Frame3 As System.Windows.Forms.GroupBox
	Public WithEvents TargetName As System.Windows.Forms.ComboBox
	Public WithEvents Frame2 As System.Windows.Forms.GroupBox
	Public WithEvents YrInit As System.Windows.Forms.Button
	Public WithEvents Exit_Renamed As System.Windows.Forms.Button
	Public WithEvents Init As System.Windows.Forms.Button
    Public WithEvents DelimBox As System.Windows.Forms.ComboBox
    Public WithEvents DelRet As System.Windows.Forms.Button
	Public WithEvents SendData As System.Windows.Forms.TextBox
	Public WithEvents TextRet As System.Windows.Forms.TextBox
	Public WithEvents SendStop As System.Windows.Forms.Button
	Public WithEvents SendStart As System.Windows.Forms.Button
	Public WithEvents Label4 As System.Windows.Forms.Label
	Public WithEvents Label2 As System.Windows.Forms.Label
	Public WithEvents Label1 As System.Windows.Forms.Label
	Public WithEvents Frame1 As System.Windows.Forms.GroupBox
	' : ȉ̃vV[W Windows tH[ fUCiŕKvłB
	'Windows tH[ fUCigĕύXł܂B
	'R[hGfB^gďCȂłB


	<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container()
        Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
        Me.SendRun = New System.Windows.Forms.Timer(Me.components)
        Me.Frame3 = New System.Windows.Forms.GroupBox()
        Me.YrAdrBox = New System.Windows.Forms.ComboBox()
        Me.Label3 = New System.Windows.Forms.Label()
        Me.Frame2 = New System.Windows.Forms.GroupBox()
        Me.TargetName = New System.Windows.Forms.ComboBox()
        Me.YrInit = New System.Windows.Forms.Button()
        Me.Exit_Renamed = New System.Windows.Forms.Button()
        Me.Init = New System.Windows.Forms.Button()
        Me.Frame1 = New System.Windows.Forms.GroupBox()
        Me.DelimBox = New System.Windows.Forms.ComboBox()
        Me.DelRet = New System.Windows.Forms.Button()
        Me.SendData = New System.Windows.Forms.TextBox()
        Me.TextRet = New System.Windows.Forms.TextBox()
        Me.SendStop = New System.Windows.Forms.Button()
        Me.SendStart = New System.Windows.Forms.Button()
        Me.Label4 = New System.Windows.Forms.Label()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.Frame3.SuspendLayout()
        Me.Frame2.SuspendLayout()
        Me.Frame1.SuspendLayout()
        Me.SuspendLayout()
        '
        'SendRun
        '
        '
        'Frame3
        '
        Me.Frame3.BackColor = System.Drawing.SystemColors.Control
        Me.Frame3.Controls.AddRange(New System.Windows.Forms.Control() {Me.YrAdrBox, Me.Label3})
        Me.Frame3.Font = New System.Drawing.Font("lr oSVbN", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
        Me.Frame3.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Frame3.Location = New System.Drawing.Point(390, 4)
        Me.Frame3.Name = "Frame3"
        Me.Frame3.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Frame3.Size = New System.Drawing.Size(147, 53)
        Me.Frame3.TabIndex = 14
        Me.Frame3.TabStop = False
        Me.Frame3.Text = "@"
        '
        'YrAdrBox
        '
        Me.YrAdrBox.BackColor = System.Drawing.SystemColors.Window
        Me.YrAdrBox.Cursor = System.Windows.Forms.Cursors.Default
        Me.YrAdrBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.YrAdrBox.Font = New System.Drawing.Font("lr oSVbN", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
        Me.YrAdrBox.ForeColor = System.Drawing.SystemColors.WindowText
        Me.YrAdrBox.Location = New System.Drawing.Point(88, 20)
        Me.YrAdrBox.Name = "YrAdrBox"
        Me.YrAdrBox.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.YrAdrBox.Size = New System.Drawing.Size(49, 23)
        Me.YrAdrBox.TabIndex = 16
        '
        'Label3
        '
        Me.Label3.BackColor = System.Drawing.SystemColors.Control
        Me.Label3.Cursor = System.Windows.Forms.Cursors.Default
        Me.Label3.Font = New System.Drawing.Font("lr oSVbN", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
        Me.Label3.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Label3.Location = New System.Drawing.Point(8, 24)
        Me.Label3.Name = "Label3"
        Me.Label3.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label3.Size = New System.Drawing.Size(77, 21)
        Me.Label3.TabIndex = 15
        Me.Label3.Text = "AhX  ="
        '
        'Frame2
        '
        Me.Frame2.BackColor = System.Drawing.SystemColors.Control
        Me.Frame2.Controls.AddRange(New System.Windows.Forms.Control() {Me.TargetName})
        Me.Frame2.Font = New System.Drawing.Font("lr oSVbN", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
        Me.Frame2.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Frame2.Location = New System.Drawing.Point(8, 4)
        Me.Frame2.Name = "Frame2"
        Me.Frame2.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Frame2.Size = New System.Drawing.Size(385, 53)
        Me.Frame2.TabIndex = 12
        Me.Frame2.TabStop = False
        Me.Frame2.Text = "@햼"
        '
        'TargetName
        '
        Me.TargetName.BackColor = System.Drawing.SystemColors.Window
        Me.TargetName.Cursor = System.Windows.Forms.Cursors.Default
        Me.TargetName.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.TargetName.Font = New System.Drawing.Font("lr oSVbN", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
        Me.TargetName.ForeColor = System.Drawing.SystemColors.WindowText
        Me.TargetName.Location = New System.Drawing.Point(8, 20)
        Me.TargetName.Name = "TargetName"
        Me.TargetName.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.TargetName.Size = New System.Drawing.Size(369, 23)
        Me.TargetName.TabIndex = 13
        '
        'YrInit
        '
        Me.YrInit.BackColor = System.Drawing.SystemColors.Control
        Me.YrInit.Cursor = System.Windows.Forms.Cursors.Default
        Me.YrInit.Font = New System.Drawing.Font("lr oSVbN", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
        Me.YrInit.ForeColor = System.Drawing.SystemColors.ControlText
        Me.YrInit.Location = New System.Drawing.Point(132, 244)
        Me.YrInit.Name = "YrInit"
        Me.YrInit.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.YrInit.Size = New System.Drawing.Size(169, 29)
        Me.YrInit.TabIndex = 4
        Me.YrInit.Text = "@̏(&Y)"
        '
        'Exit_Renamed
        '
        Me.Exit_Renamed.BackColor = System.Drawing.SystemColors.Control
        Me.Exit_Renamed.Cursor = System.Windows.Forms.Cursors.Default
        Me.Exit_Renamed.Font = New System.Drawing.Font("lr oSVbN", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
        Me.Exit_Renamed.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Exit_Renamed.Location = New System.Drawing.Point(424, 244)
        Me.Exit_Renamed.Name = "Exit_Renamed"
        Me.Exit_Renamed.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Exit_Renamed.Size = New System.Drawing.Size(117, 29)
        Me.Exit_Renamed.TabIndex = 2
        Me.Exit_Renamed.Text = "I(&X)"
        '
        'Init
        '
        Me.Init.BackColor = System.Drawing.SystemColors.Control
        Me.Init.Cursor = System.Windows.Forms.Cursors.Default
        Me.Init.Font = New System.Drawing.Font("lr oSVbN", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
        Me.Init.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Init.Location = New System.Drawing.Point(8, 244)
        Me.Init.Name = "Init"
        Me.Init.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Init.Size = New System.Drawing.Size(121, 29)
        Me.Init.TabIndex = 1
        Me.Init.Text = "(&I)"
        '
        'Frame1
        '
        Me.Frame1.BackColor = System.Drawing.SystemColors.Control
        Me.Frame1.Controls.AddRange(New System.Windows.Forms.Control() {Me.DelimBox, Me.DelRet, Me.SendData, Me.TextRet, Me.SendStop, Me.SendStart, Me.Label4, Me.Label2, Me.Label1})
        Me.Frame1.Font = New System.Drawing.Font("lr oSVbN", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
        Me.Frame1.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Frame1.Location = New System.Drawing.Point(8, 66)
        Me.Frame1.Name = "Frame1"
        Me.Frame1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Frame1.Size = New System.Drawing.Size(529, 169)
        Me.Frame1.TabIndex = 3
        Me.Frame1.TabStop = False
        Me.Frame1.Text = "f[^M"
        '
        'DelimBox
        '
        Me.DelimBox.BackColor = System.Drawing.SystemColors.Window
        Me.DelimBox.Cursor = System.Windows.Forms.Cursors.Default
        Me.DelimBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.DelimBox.Font = New System.Drawing.Font("lr oSVbN", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
        Me.DelimBox.ForeColor = System.Drawing.SystemColors.WindowText
        Me.DelimBox.Items.AddRange(New Object() {"gp", "CR+LF", "CR", "LF"})
        Me.DelimBox.Location = New System.Drawing.Point(88, 132)
        Me.DelimBox.Name = "DelimBox"
        Me.DelimBox.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.DelimBox.Size = New System.Drawing.Size(97, 23)
        Me.DelimBox.TabIndex = 17
        '
        'DelRet
        '
        Me.DelRet.BackColor = System.Drawing.SystemColors.Control
        Me.DelRet.Cursor = System.Windows.Forms.Cursors.Default
        Me.DelRet.Font = New System.Drawing.Font("lr oSVbN", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
        Me.DelRet.ForeColor = System.Drawing.SystemColors.ControlText
        Me.DelRet.Location = New System.Drawing.Point(411, 72)
        Me.DelRet.Name = "DelRet"
        Me.DelRet.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.DelRet.Size = New System.Drawing.Size(110, 25)
        Me.DelRet.TabIndex = 11
        Me.DelRet.Text = "߂l(&R)"
        '
        'SendData
        '
        Me.SendData.AcceptsReturn = True
        Me.SendData.AutoSize = False
        Me.SendData.BackColor = System.Drawing.SystemColors.Window
        Me.SendData.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.SendData.Font = New System.Drawing.Font("lr oSVbN", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
        Me.SendData.ForeColor = System.Drawing.SystemColors.WindowText
        Me.SendData.Location = New System.Drawing.Point(12, 44)
        Me.SendData.MaxLength = 0
        Me.SendData.Name = "SendData"
        Me.SendData.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.SendData.Size = New System.Drawing.Size(509, 25)
        Me.SendData.TabIndex = 9
        Me.SendData.Text = ""
        '
        'TextRet
        '
        Me.TextRet.AcceptsReturn = True
        Me.TextRet.AutoSize = False
        Me.TextRet.BackColor = System.Drawing.SystemColors.Window
        Me.TextRet.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.TextRet.Font = New System.Drawing.Font("lr oSVbN", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
        Me.TextRet.ForeColor = System.Drawing.SystemColors.WindowText
        Me.TextRet.Location = New System.Drawing.Point(12, 100)
        Me.TextRet.MaxLength = 0
        Me.TextRet.Name = "TextRet"
        Me.TextRet.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.TextRet.Size = New System.Drawing.Size(509, 25)
        Me.TextRet.TabIndex = 7
        Me.TextRet.Text = ""
        '
        'SendStop
        '
        Me.SendStop.BackColor = System.Drawing.SystemColors.Control
        Me.SendStop.Cursor = System.Windows.Forms.Cursors.Default
        Me.SendStop.Font = New System.Drawing.Font("lr oSVbN", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
        Me.SendStop.ForeColor = System.Drawing.SystemColors.ControlText
        Me.SendStop.Location = New System.Drawing.Point(376, 132)
        Me.SendStop.Name = "SendStop"
        Me.SendStop.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.SendStop.Size = New System.Drawing.Size(145, 29)
        Me.SendStop.TabIndex = 6
        Me.SendStop.Text = "f[^M~(&E)"
        '
        'SendStart
        '
        Me.SendStart.BackColor = System.Drawing.SystemColors.Control
        Me.SendStart.Cursor = System.Windows.Forms.Cursors.Default
        Me.SendStart.Font = New System.Drawing.Font("lr oSVbN", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
        Me.SendStart.ForeColor = System.Drawing.SystemColors.ControlText
        Me.SendStart.Location = New System.Drawing.Point(228, 132)
        Me.SendStart.Name = "SendStart"
        Me.SendStart.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.SendStart.Size = New System.Drawing.Size(145, 29)
        Me.SendStart.TabIndex = 5
        Me.SendStart.Text = "f[^MJn(&S)"
        '
        'Label4
        '
        Me.Label4.BackColor = System.Drawing.SystemColors.Control
        Me.Label4.Cursor = System.Windows.Forms.Cursors.Default
        Me.Label4.Font = New System.Drawing.Font("lr oSVbN", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
        Me.Label4.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Label4.Location = New System.Drawing.Point(16, 136)
        Me.Label4.Name = "Label4"
        Me.Label4.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label4.Size = New System.Drawing.Size(65, 17)
        Me.Label4.TabIndex = 18
        Me.Label4.Text = "f~^"
        '
        'Label2
        '
        Me.Label2.BackColor = System.Drawing.SystemColors.Control
        Me.Label2.Cursor = System.Windows.Forms.Cursors.Default
        Me.Label2.Font = New System.Drawing.Font("lr oSVbN", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
        Me.Label2.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Label2.Location = New System.Drawing.Point(16, 24)
        Me.Label2.Name = "Label2"
        Me.Label2.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label2.Size = New System.Drawing.Size(93, 21)
        Me.Label2.TabIndex = 10
        Me.Label2.Text = "Mf[^"
        '
        'Label1
        '
        Me.Label1.BackColor = System.Drawing.SystemColors.Control
        Me.Label1.Cursor = System.Windows.Forms.Cursors.Default
        Me.Label1.Font = New System.Drawing.Font("lr oSVbN", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(128, Byte))
        Me.Label1.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Label1.Location = New System.Drawing.Point(16, 80)
        Me.Label1.Name = "Label1"
        Me.Label1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label1.Size = New System.Drawing.Size(133, 21)
        Me.Label1.TabIndex = 8
        Me.Label1.Text = "߂l(Xe[^X)"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 12)
        Me.ClientSize = New System.Drawing.Size(546, 282)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Frame3, Me.Frame2, Me.YrInit, Me.Exit_Renamed, Me.Init, Me.Frame1})
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        Me.Location = New System.Drawing.Point(403, 296)
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "Form1"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.Manual
        Me.Text = "dRg["
        Me.Frame3.ResumeLayout(False)
        Me.Frame2.ResumeLayout(False)
        Me.Frame1.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub
#End Region 
#Region "AbvO[h EBU[h̃T|[g R[h"
	Private Shared m_vb6FormDefInstance As Form1
	Private Shared m_InitializingDefInstance As Boolean
	Public Shared Property DefInstance() As Form1
		Get
			If m_vb6FormDefInstance Is Nothing OrElse m_vb6FormDefInstance.IsDisposed Then
				m_InitializingDefInstance = True
				m_vb6FormDefInstance = New Form1()
				m_InitializingDefInstance = False
			End If
			DefInstance = m_vb6FormDefInstance
		End Get
		Set
			m_vb6FormDefInstance = Value
		End Set
	End Property
#End Region 
    Dim Mode As Integer                                     '[h̐ݒ
    Dim SendBuf As String                                   'Mobt@
    Dim DVCNT As Integer                                    '@[gJEgłB
    Dim DVSTOP As Integer                                   '@~܂B
    Dim SData As String                                     'dł̑Mf[^
    Dim Adrs As Integer                                     'AhX쐬Ɏgp
    Dim ErrText As String                                   'eLXg\p
    Dim Srlen As Integer                                    '̒
    Dim Delim As Integer                                    'f~^
    Dim gChCmd As GCHandle                                  'CmdzpGCHandle

	
    Private Sub DelimBox_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles DelimBox.SelectedIndexChanged

        Eoi = 1                                  'Eoi = 0:gpȂ/1:gp

        Delim = DelimBox.SelectedIndex
        Ret = GpDelim(Delim, Eoi)                'f~^R[h(EOI)o̎w܂B(w肵ȂĂł)

    End Sub


    '///// [ tH[[h ] ///////////////////////////////////////////////////////////////////
    Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load

        For Adrs = 0 To 30                                  '@AhX쐬܂B
            YrAdrBox.Items.Add(CStr(Adrs))
        Next Adrs

        ErrText = ""
        TargetName.Items.Add("[ YOKOGAWA Digital Voltage Source TYPE 2553 ]")
        TargetName.Items.Add("[ ADVATEST Voltage Source TR6150 ]")
        TargetName.SelectedIndex = 0

        YrAdrBox.Text = CStr(8)                             'ݒ
        DVCNT = 0

        DVSTOP = 0                                          'd~
        SendBuf = "V3P0S00000O1"
        Srlen = Len(SendBuf)
        SendData.Text = SendBuf

        DelimBox.SelectedIndex = 1                          'ݒ

        'PinnednhCmdɕz
        If gChCmd.IsAllocated = False Then
            gChCmd = GCHandle.Alloc(Cmd, GCHandleType.Pinned)
        End If

        'PinnednhŃIuWFNg̃AhX擾
        pCmd = gChCmd.AddrOfPinnedObject()

    End Sub

    '///// [  ] ///////////////////////////////////////////////////////////////////////////
    Private Sub Init_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Init.Click

        Ret = GpibInit(ErrText)                             'SubClassɂ܂B
        If (Ret = 1) Then GoTo Err_Renamed
        Ret = GpBoardsts(&HAS, Mode)

        If Mode = 1 Then                                    '[h̃`FbN
            TextRet.Text = "̋@̓}X^ł͂܂B"
            Exit Sub
        End If

        If YrAdrBox.Items.Count = 31 Then                   '}CAhXXg폜܂B
            YrAdrBox.Items.RemoveAt((MyAddr))
            If MyAddr = YrAddr Then
                YrAdrBox.SelectedIndex = 0
            End If
        End If

        Select Case YrAdrBox.Text
            Case CStr(0)
                '܂B
            Case CStr(1)
                Ret = GpSdc(YrAddr)                         'I@܂B
                If CheckRet("GpSdc", Ret, ErrText) = 1 Then GoTo Err_Renamed
                SendBuf = "V5L3L7"
                Srlen = Len(SendBuf)
                Cmd(0) = 2
                Cmd(1) = MyAddr
                Cmd(2) = YrAddr
                Ret = GpTalk(pCmd, Srlen, SendBuf)
                If CheckRet("GpTalk", Ret, ErrText) = 1 Then GoTo Err_Renamed
        End Select

        Cmd(0) = 2                                          'R}h
        Cmd(1) = &H3FS                                      'AX^UNL
        Cmd(2) = &H5FS                                      'Ag[N^UNT
        Ret = GpComand(pCmd)                                'R}h𑗐M
        If CheckRet("GpComand", Ret, ErrText) = 1 Then GoTo Err_Renamed

        If (Ret = 0) Or ((Ret And &HFFS) = 0) Then
            '@킪펞SRQ𑗐MĂPP̖߂l̓G[255SRQmF1256ɂȂ܂B
            ErrText = "܂B@햼ƃAhXݒ肵ĂB"
        End If

        Call DelimBox_SelectedIndexChanged(DelimBox, New System.EventArgs())

Err_Renamed:
        TextRet.Text = ErrText

    End Sub

    '///// [ R}hM(^C}) ] /////////////////////////////////////////////////////////////
    Private Sub SendRun_Tick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles SendRun.Tick

        Select Case (TargetName.SelectedIndex)              'foCXŃf[^M̕ύX
            Case 0
                SendBuf = "V3P0S" & VB.Right("0" & DVCNT.ToString, 2) & "000O1" : Srlen = Len(SendBuf)
                If DVCNT = 0 Then SendBuf = "V3P0S00000O0" : Srlen = Len(SendBuf)
                If DVCNT >= 12 Then DVCNT = 0 Else DVCNT = DVCNT + 1
                SendData.Text = SendBuf

                Srlen = Len(SendBuf)
                Cmd(0) = 2
                Cmd(1) = MyAddr
                Cmd(2) = YrAddr
                Ret = GpTalk(pCmd, Srlen, SendBuf)
                If CheckRet("GpTalk", Ret, ErrText) = 1 Then GoTo TimerOff

                Ret = GpGet(YrAddr)
                If CheckRet("GpGet", Ret, ErrText) = 1 Then GoTo TimerOff
                ErrText = "f[^MI܂"
            Case 1
                SendBuf = "D" & VB.Right("0" & DVCNT.ToString, 2) & "E" : Srlen = Len(SendBuf)
                If DVCNT > 10 Then DVCNT = 0 Else DVCNT = DVCNT + 1
                SendData.Text = SendBuf
                Srlen = Len(SendBuf)

                Cmd(0) = 2
                Cmd(1) = MyAddr
                Cmd(2) = YrAddr
                Ret = GpTalk(pCmd, Srlen, SendBuf)
                If CheckRet("GpTalk", Ret, ErrText) = 1 Then GoTo TimerOff

                Ret = GpGet(YrAddr)
                If CheckRet("GpGet", Ret, ErrText) = 1 Then GoTo TimerOff
                TextRet.Text = "f[^MI܂"
        End Select
        GoTo TimerEnd

TimerOff:
        SendRun.Enabled = False

TimerEnd:
        Cmd(0) = 2                                          'R}h
        Cmd(1) = &H3FS                                      'AX^UNL
        Cmd(2) = &H5FS                                      'Ag[N^UNT
        Ret = GpComand(pCmd)                                'R}hM

    End Sub

    '///// [ MJn ] /////////////////////////////////////////////////////////////////////////
    Private Sub SendStart_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles SendStart.Click

        SendRun.Enabled = True                              '^C}Jn

    End Sub

    '///// [ M~ ] /////////////////////////////////////////////////////////////////////////
    Private Sub SendStop_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles SendStop.Click

        SendRun.Enabled = False                             '^C}~

    End Sub

    '///// [ ߂l ] /////////////////////////////////////////////////////////////////////
    Private Sub DelRet_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles DelRet.Click

        TextRet.Text = ""

    End Sub

    '///// [ ^[QbgύXɂ鑗Mf[^̕ύX ] /////////////////////////////////////////////
    Private Sub TargetName_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles TargetName.SelectedIndexChanged

        Select Case (TargetName.SelectedIndex)              '@̑I
            Case 0                                          'YOKOGAWAI
                SData = "V3P0"
                SendData.Text = "V3P0S00000O1"
            Case 1                                          'ADVANTESTI
                SData = "V5L3L7"
                SendData.Text = "V5L3L7"
        End Select

    End Sub

    '///// [ @AhXύX ] /////////////////////////////////////////////////////////////
    Private Sub YrAdrBox_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles YrAdrBox.SelectedIndexChanged

        YrAddr = CInt(YrAdrBox.Text)

    End Sub

    '///// [ @AhX̏(@̊mF) ] /////////////////////////////////////////
    Private Sub YrInit_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles YrInit.Click

        Cmd(0) = 2
        Cmd(1) = MyAddr
        Cmd(2) = YrAddr
        Srlen = Len(SData)
        Ret = GpTalk(pCmd, Srlen, SData)                    'R}h𑗐M
        If (Ret And &HFFS) > 0 Then                         'G[̏
            CheckRet("GpTalk", Ret, ErrText)
            TextRet.Text = ErrText
        Else                                                'I
            TextRet.Text = "@܂B"
        End If

    End Sub

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

        Ret = GpibExit()                                    'SubClassɂ܂B
        Me.Close()                                          '_CAOI܂B

    End Sub

    Private Sub Form1_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
        'GCHandlẻ
        If gChCmd.IsAllocated = True Then
            gChCmd.Free()
        End If
    End Sub
End Class