Option Strict Off
Option Explicit On 
Imports System.Runtime.InteropServices
Imports VB = Microsoft.VisualBasic
Friend Class Form1
	Inherits System.Windows.Forms.Form
#Region "Windows Form Designer generated code "
	Public Sub New()
		MyBase.New()
		If m_vb6FormDefInstance Is Nothing Then
			If m_InitializingDefInstance Then
				m_vb6FormDefInstance = Me
			Else
				Try 
					'For the start-up form, the first instance created is the default instance.
					If System.Reflection.Assembly.GetExecutingAssembly.EntryPoint.DeclaringType Is Me.GetType Then
						m_vb6FormDefInstance = Me
					End If
				Catch
				End Try
			End If
		End If
		'This call is required by the Windows Form Designer.
		InitializeComponent()
	End Sub
	'Form overrides dispose to clean up the component list.
	Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean)
		If Disposing Then
			If Not components Is Nothing Then
				components.Dispose()
			End If
		End If
		MyBase.Dispose(Disposing)
	End Sub
	'Required by the Windows Form Designer
	Private components As System.ComponentModel.IContainer
	Public ToolTip1 As System.Windows.Forms.ToolTip
	Public WithEvents DelimBox As System.Windows.Forms.ComboBox
	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 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 Label2 As System.Windows.Forms.Label
	Public WithEvents Label1 As System.Windows.Forms.Label
	Public WithEvents Frame1 As System.Windows.Forms.GroupBox
	Public WithEvents Label4 As System.Windows.Forms.Label
	'NOTE: The following procedure is required by the Windows Form Designer
	'It can be modified using the Windows Form Designer.
	'Do not modify it using the code editor.
	<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container()
        Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
        Me.DelimBox = New System.Windows.Forms.ComboBox()
        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.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.Label2 = New System.Windows.Forms.Label()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.Label4 = New System.Windows.Forms.Label()
        Me.Frame3.SuspendLayout()
        Me.Frame2.SuspendLayout()
        Me.Frame1.SuspendLayout()
        Me.SuspendLayout()
        '
        '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.ForeColor = System.Drawing.SystemColors.WindowText
        Me.DelimBox.Items.AddRange(New Object() {"Not Use", "CR+LF", "CR", "LF"})
        Me.DelimBox.Location = New System.Drawing.Point(200, 240)
        Me.DelimBox.Name = "DelimBox"
        Me.DelimBox.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.DelimBox.Size = New System.Drawing.Size(89, 21)
        Me.DelimBox.TabIndex = 16
        '
        'SendRun
        '
        '
        'Frame3
        '
        Me.Frame3.BackColor = System.Drawing.SystemColors.Control
        Me.Frame3.Controls.AddRange(New System.Windows.Forms.Control() {Me.YrAdrBox, Me.Label3})
        Me.Frame3.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Frame3.Location = New System.Drawing.Point(384, 6)
        Me.Frame3.Name = "Frame3"
        Me.Frame3.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Frame3.Size = New System.Drawing.Size(155, 53)
        Me.Frame3.TabIndex = 13
        Me.Frame3.TabStop = False
        '
        '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.ForeColor = System.Drawing.SystemColors.WindowText
        Me.YrAdrBox.Location = New System.Drawing.Point(98, 20)
        Me.YrAdrBox.Name = "YrAdrBox"
        Me.YrAdrBox.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.YrAdrBox.Size = New System.Drawing.Size(49, 21)
        Me.YrAdrBox.TabIndex = 15
        '
        '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(20, 24)
        Me.Label3.Name = "Label3"
        Me.Label3.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label3.Size = New System.Drawing.Size(85, 21)
        Me.Label3.TabIndex = 14
        Me.Label3.Text = "Address  ="
        '
        'Frame2
        '
        Me.Frame2.BackColor = System.Drawing.SystemColors.Control
        Me.Frame2.Controls.AddRange(New System.Windows.Forms.Control() {Me.TargetName})
        Me.Frame2.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Frame2.Location = New System.Drawing.Point(8, 6)
        Me.Frame2.Name = "Frame2"
        Me.Frame2.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Frame2.Size = New System.Drawing.Size(379, 53)
        Me.Frame2.TabIndex = 11
        Me.Frame2.TabStop = False
        Me.Frame2.Text = "Address of Device name"
        '
        '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.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(363, 21)
        Me.TargetName.TabIndex = 12
        '
        'YrInit
        '
        Me.YrInit.BackColor = System.Drawing.SystemColors.Control
        Me.YrInit.Cursor = System.Windows.Forms.Cursors.Default
        Me.YrInit.Enabled = False
        Me.YrInit.ForeColor = System.Drawing.SystemColors.ControlText
        Me.YrInit.Location = New System.Drawing.Point(304, 238)
        Me.YrInit.Name = "YrInit"
        Me.YrInit.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.YrInit.Size = New System.Drawing.Size(127, 27)
        Me.YrInit.TabIndex = 3
        Me.YrInit.Text = "&Device Initialize"
        '
        'Exit_Renamed
        '
        Me.Exit_Renamed.BackColor = System.Drawing.SystemColors.Control
        Me.Exit_Renamed.Cursor = System.Windows.Forms.Cursors.Default
        Me.Exit_Renamed.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Exit_Renamed.Location = New System.Drawing.Point(436, 238)
        Me.Exit_Renamed.Name = "Exit_Renamed"
        Me.Exit_Renamed.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Exit_Renamed.Size = New System.Drawing.Size(103, 27)
        Me.Exit_Renamed.TabIndex = 1
        Me.Exit_Renamed.Text = "E&xit"
        '
        'Init
        '
        Me.Init.BackColor = System.Drawing.SystemColors.Control
        Me.Init.Cursor = System.Windows.Forms.Cursors.Default
        Me.Init.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Init.Location = New System.Drawing.Point(8, 238)
        Me.Init.Name = "Init"
        Me.Init.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Init.Size = New System.Drawing.Size(107, 27)
        Me.Init.TabIndex = 0
        Me.Init.Text = "&Initialize"
        '
        'Frame1
        '
        Me.Frame1.BackColor = System.Drawing.SystemColors.Control
        Me.Frame1.Controls.AddRange(New System.Windows.Forms.Control() {Me.DelRet, Me.SendData, Me.TextRet, Me.SendStop, Me.SendStart, Me.Label2, Me.Label1})
        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(531, 165)
        Me.Frame1.TabIndex = 2
        Me.Frame1.TabStop = False
        Me.Frame1.Text = "Send / Receive"
        '
        'DelRet
        '
        Me.DelRet.BackColor = System.Drawing.SystemColors.Control
        Me.DelRet.Cursor = System.Windows.Forms.Cursors.Default
        Me.DelRet.ForeColor = System.Drawing.SystemColors.ControlText
        Me.DelRet.Location = New System.Drawing.Point(422, 68)
        Me.DelRet.Name = "DelRet"
        Me.DelRet.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.DelRet.Size = New System.Drawing.Size(99, 23)
        Me.DelRet.TabIndex = 10
        Me.DelRet.Text = "De&lete"
        '
        '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.ForeColor = System.Drawing.SystemColors.WindowText
        Me.SendData.Location = New System.Drawing.Point(12, 38)
        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 = 8
        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.ForeColor = System.Drawing.SystemColors.WindowText
        Me.TextRet.Location = New System.Drawing.Point(12, 96)
        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 = 6
        Me.TextRet.Text = ""
        '
        'SendStop
        '
        Me.SendStop.BackColor = System.Drawing.SystemColors.Control
        Me.SendStop.Cursor = System.Windows.Forms.Cursors.Default
        Me.SendStop.Enabled = False
        Me.SendStop.ForeColor = System.Drawing.SystemColors.ControlText
        Me.SendStop.Location = New System.Drawing.Point(380, 128)
        Me.SendStop.Name = "SendStop"
        Me.SendStop.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.SendStop.Size = New System.Drawing.Size(141, 29)
        Me.SendStop.TabIndex = 5
        Me.SendStop.Text = "S&end Stop"
        '
        'SendStart
        '
        Me.SendStart.BackColor = System.Drawing.SystemColors.Control
        Me.SendStart.Cursor = System.Windows.Forms.Cursors.Default
        Me.SendStart.Enabled = False
        Me.SendStart.ForeColor = System.Drawing.SystemColors.ControlText
        Me.SendStart.Location = New System.Drawing.Point(228, 128)
        Me.SendStart.Name = "SendStart"
        Me.SendStart.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.SendStart.Size = New System.Drawing.Size(145, 29)
        Me.SendStart.TabIndex = 4
        Me.SendStart.Text = "&Send Start"
        '
        '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(16, 20)
        Me.Label2.Name = "Label2"
        Me.Label2.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label2.Size = New System.Drawing.Size(73, 15)
        Me.Label2.TabIndex = 9
        Me.Label2.Text = "Send Data"
        '
        '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(16, 76)
        Me.Label1.Name = "Label1"
        Me.Label1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label1.Size = New System.Drawing.Size(151, 17)
        Me.Label1.TabIndex = 7
        Me.Label1.Text = "Return value (Status)"
        '
        '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(128, 240)
        Me.Label4.Name = "Label4"
        Me.Label4.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label4.Size = New System.Drawing.Size(65, 25)
        Me.Label4.TabIndex = 17
        Me.Label4.Text = "Delimiter"
        '
        'Form1
        '
        Me.ClientSize = New System.Drawing.Size(550, 271)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.DelimBox, Me.Frame3, Me.Frame2, Me.YrInit, Me.Exit_Renamed, Me.Init, Me.Frame1, Me.Label4})
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        Me.Location = New System.Drawing.Point(141, 160)
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "Form1"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.Manual
        Me.Text = "Voltage source control"
        Me.Frame3.ResumeLayout(False)
        Me.Frame2.ResumeLayout(False)
        Me.Frame1.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub
#End Region 
#Region "Upgrade Support "
	Private Shared m_vb6FormDefInstance As 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 SendBuf As String               'A sending buffer
    Dim DVCNT As Integer                'It is the count which does an equipment remote.
    Dim DVSTOP As Integer               'An equipment is made to hang-up.
    Dim SData As String                 'Transmit data in a constant voltage source
    Dim Adrs As Integer                 'It is used at the time of address making
    Dim ErrText As String               'Text for display
    Dim Srlen As Integer                'A length of a character string
    Dim Delim As Integer                'Delimiter
    Dim gChCmd As GCHandle              'GCHandle for cmd array

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

        Eoi = 1

        Delim = DelimBox.SelectedIndex
        Ret = GpDelim(Delim, Eoi)

    End Sub

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

        For Adrs = 0 To 30              'Address of device address is made.
            YrAdrBox.Items.Add(CStr(Adrs))
        Next Adrs

        DelimBox.Text = "CR+LF"

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

        YrAdrBox.Text = CStr(8)         'Initial setting
        DVCNT = 0

        DVSTOP = 0                      'A constant voltage source operation stopped state
        SendBuf = "V3P0S00000O1"
        Srlen = Len(SendBuf)
        SendData.Text = SendBuf

        'Specify Pinned handle to Cmd
        If gChCmd.IsAllocated = False Then
            gChCmd = GCHandle.Alloc(Cmd, GCHandleType.Pinned)
        End If

        'Get address object by Pinned handle
        pCmd = gChCmd.AddrOfPinnedObject()

    End Sub

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

        Ret = GpibInit(ErrText)             'SubClass.bas
        If Ret = 1 Then GoTo Err_Renamed

        If YrAdrBox.Items.Count = 31 Then   'MyAddress is deleted from a list.
            YrAdrBox.Items.RemoveAt((MyAddr))
            If MyAddr = YrAddr Then
                YrAdrBox.SelectedIndex = 0
            End If
        End If

        YrAddr = CInt(YrAdrBox.Text)

        Select Case YrAdrBox.Text
            Case CStr(0)
                'It is not done at all.
            Case CStr(1)
                Ret = GpSdc(YrAddr)         ' Selection Address of device is initialized.
                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                      'Number of command
        Cmd(1) = &H3FS                  'Unlisten/UNL
        Cmd(2) = &H5FS                  'Untalken/UNT
        Ret = GpComand(pCmd) 'command sending
        If CheckRet("GpComand", Ret, ErrText) = 1 Then GoTo Err_Renamed

        If (Ret = 0) Or ((Ret And &HFFS) = 0) Then
            'When Address of device always transmits SRQ,
            'a returning value of PP amounts to 256.
            ErrText = "Initialization was completed.Please set up an Address of device name and address."
            YrInit.Enabled = True
        End If

        Call DelimBox_SelectedIndexChanged(DelimBox, New System.EventArgs())
Err_Renamed:
        TextRet.Text = ErrText

    End Sub

    Private Sub SendRun_Tick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles SendRun.Tick '[ Command sending(Timer) ]

        Select Case (TargetName.SelectedIndex)      'In a device name change of data sending
            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 = "Data sending was terminated."
            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 = "Data sending was terminated."
        End Select
        GoTo TimerEnd

TimerOff:
        SendRun.Enabled = False
        SendStart.Enabled = True
        SendStop.Enabled = False

TimerEnd:
        Cmd(0) = 2                  'Number of command
        Cmd(1) = &H3FS              'Unlisten/UNL
        Cmd(2) = &H5FS              'Untalken/UNT
        Ret = GpComand(pCmd)        'Command sending

    End Sub

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

        YrInit.Enabled = False
        SendStart.Enabled = False
        SendStop.Enabled = True

        SendRun.Enabled = True      'A timer start

    End Sub

    Private Sub SendStop_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles SendStop.Click '[ Sending hang-up ]

        YrInit.Enabled = True
        SendStart.Enabled = True
        SendStop.Enabled = False

        SendRun.Enabled = False     'Time switch hang-up

    End Sub

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

        TextRet.Text = ""

    End Sub

    Private Sub TargetName_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles TargetName.SelectedIndexChanged '[ Change of transmit data by target change ]

        Select Case (TargetName.SelectedIndex)      'A selection of Address of device
            Case 0                                  'At YOKOGAWA a selection
                SData = "V3P0"
                SendData.Text = "V3P0S00000O1"
            Case 1                                  'At ADVANTEST a selection
                SData = "V5L3L7"
                SendData.Text = "V5L3L7"
        End Select

    End Sub

    Private Sub YrAdrBox_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles YrAdrBox.SelectedIndexChanged '[ An Address of device address modification ]

        YrAddr = CInt(YrAdrBox.Text)

    End Sub

    Private Sub YrInit_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles YrInit.Click '[ Initialization of Address of device(A confirmation of Address of device) ]

        Cmd(0) = 2
        Cmd(1) = MyAddr
        Cmd(2) = YrAddr
        Srlen = Len(SData)
        Ret = GpTalk(pCmd, Srlen, SData)        'At a command sending
        If (Ret And &HFFS) > 0 Then             'Processing at the time of an error
            CheckRet("GpTalk", Ret, ErrText)
            TextRet.Text = ErrText
        Else                                    'Normal termination
            SendStart.Enabled = True
            SendData.Enabled = False
            TextRet.Text = "Address of device was initialized."
        End If

    End Sub

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

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

    End Sub

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

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