﻿Public Class Form1

    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_FormClosed(sender As Object, e As FormClosedEventArgs) Handles MyBase.FormClosed
        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 'ƒŠƒXƒgƒ{ƒbƒNƒX‚ÌŒÀŠ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
    '   FuntionF 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 (*.*)|*.*"
            Try
                '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)
            Catch ex As Exception
                Exit Sub
            End Try
        End If
    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
            Do
                If (m.WParam.ToInt32 And &H20S) <> 0 Then
                    'Set Equipment ID, delimiter and EOI
                    If funcSetParam() = True Then Exit Do
                    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
            Loop While 0
            '----------------------------------------
            '   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
