VERSION 5.00
Begin VB.Form SelComDialog 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Select Comm Port"
   ClientHeight    =   1845
   ClientLeft      =   2760
   ClientTop       =   3750
   ClientWidth     =   2880
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   1845
   ScaleWidth      =   2880
   ShowInTaskbar   =   0   'False
   Begin VB.ComboBox cmbComPort 
      Height          =   315
      ItemData        =   "SelComDialog.frx":0000
      Left            =   720
      List            =   "SelComDialog.frx":0010
      TabIndex        =   2
      Text            =   "COM1"
      Top             =   720
      Width           =   1095
   End
   Begin VB.CommandButton CancelButton 
      Caption         =   "Quit"
      Height          =   375
      Left            =   120
      TabIndex        =   1
      Top             =   1320
      Width           =   1215
   End
   Begin VB.CommandButton OKButton 
      Caption         =   "OK"
      Height          =   375
      Left            =   1440
      TabIndex        =   0
      Top             =   1320
      Width           =   1215
   End
   Begin VB.Label lblMessage 
      Caption         =   "No available serial ports found."
      ForeColor       =   &H000000FF&
      Height          =   255
      Left            =   120
      TabIndex        =   3
      Top             =   240
      Width           =   2295
   End
End
Attribute VB_Name = "SelComDialog"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Option Explicit

Public CommPort As Integer

Private Sub CancelButton_Click()
    End
End Sub

Private Sub Form_Load()
    
    Dim i As Integer
    cmbComPort.Clear
    For i = 1 To 16
        If COMAvailable(i) Then
            cmbComPort.AddItem "COM" + CStr(i)
        End If
    Next
    
    If cmbComPort.ListCount < 1 Then
        lblMessage.Caption = "No available serial ports found."
        lblMessage.ForeColor = &HFF&
        cmbComPort.Enabled = False
        OKButton.Enabled = False
    Else
        lblMessage.Caption = "Select a COM port:"
        lblMessage.ForeColor = &H80000008
        cmbComPort.ListIndex = 0
    End If

End Sub

Private Sub OKButton_Click()
    CommPort = CDec(Mid$(cmbComPort.Text, 4))
    Unload Me
End Sub
