Private Sub btnCollectDisplayData_Click()
'
' This command is responsible for commanding the Analyzer to send 1024 bytes of data
'
Dim tmp As String

    ' disable the button
    btnCollectDisplayData.Enabled = False
    
    On Error GoTo CollectDisplayDataError
        
    ' Initialize the correct Comm Port
    cntlComm.CommPort = iCommPort
    cntlComm.Settings = strCommSettings
    cntlComm.InputLen = 0
    
    ' Open the Comm Port
    If Not cntlComm.PortOpen Then
           cntlComm.PortOpen = True
    End If
    'cntlComm.InputMode = comInputModeBinary
    
    ' Send an initialization string to the analyzer
    cntlComm.Output = vInitString
    
    ' Wait for data to come back to the serial port.
    Do
        DoEvents
    Loop Until cntlComm.InBufferCount = iMaxValues
    
    ' *** DisplayData cntlComm.Input
    
    ' Close the serial port
    cntlComm.PortOpen = False
    
    ' reenable it
    btnCollectDisplayData.Enabled = True
    
    Exit Sub
    
CollectDisplayDataError:
        MsgBox "Error in btnCollectDisplayData_Click routine" & vbCr & Err.Description
        Resume Next
    
End Sub
============================================================================================
Private Sub btnCollectDisplayData_Click()
    
    ' disable the button
    btnCollectDisplayData.Enabled = False
    
    Dim x As Integer
    Dim filenum As Integer
    Dim testdata As Variant
    
    testdata = ""
    filenum = FreeFile
    
    ' Initialize the correct Comm Port
    cntlComm.CommPort = iCommPort
    cntlComm.Settings = strCommSettings
    cntlComm.InputLen = 0
    
    ' for testing only
    Open frmCommSettings.cmboCommPort.Text For Input As filenum

    ' wait for 'S'tart
    Do While EOF(filenum)
        DoEvents
        Do While Not EOF(filenum)
            Input #filenum, testdata
        Loop
        If testdata = "S" Then
            Exit Do
        Else
            testdata = ""
        End If
    Loop

    ' gather the scan setup
    If Not EOF(filenum) Then
        Input #filenum, Scan_Start
        Input #filenum, Scan_End
        Input #filenum, Scan_Step
    End If

    ' display the data
    Dim labelcounter As Integer
    labelcounter = 0

    x = 0
    testdata = ""

    ' initial display
    Do While Not EOF(filenum) And Not testdata = "E" And x < iMaxValues
        If Not EOF(filenum) Then
            Input #filenum, testdata
            If Not testdata = "E" Then
                thedata(x, 0) = testdata
                thedata(x, 1) = 0
                thedata(x, 2) = 0
            Else
                Exit Do
            End If
        Else
            Exit Do
        End If
        x = x + 1
    Loop

    NumPoints = x

    ' reenable it
    btnCollectDisplayData.Enabled = True
    
End Sub

