Version 1.0 Class
Attribute VB_Name = "Application"
Attribute VB_Creatable = True
Attribute VB_Exposed = True
Option Explicit

' Dial method -- same as clicking the Dial Phone Number
' menu item in the user interface.
Sub Dial(Optional PhoneNumber)
Attribute Dial.VB_HelpID = 1100
Attribute Dial.VB_Description = "Dials a phone number."
    If IsMissing(PhoneNumber) Then
        Form1.MDial_Click
    Else
        Form1.DialNumber CStr(PhoneNumber)
    End If
End Sub

' Hangup method -- same as clicking the Hangup Phone menu
' item in the user interface.
Sub HangUp()
    Form1.MHangup_Click
End Sub

' PortOpen property
' Read/Write, Boolean
'   True if Comm port is open.
'   False if Comm port is closed.
Property Get PortOpen() As Boolean
    PortOpen = Form1.MSComm1.PortOpen
End Property

Property Let PortOpen(bSetting As Boolean)
    Form1.MSComm1.PortOpen = bSetting
End Property

' SendLine method.
' Sends a command string to the VB Terminal window.
Sub SendLine(strText As String)
    If Form1.MSComm1.PortOpen Then
       ' Send the line to the comm port.
       Form1.MSComm1.Output = strText & Chr(13)
       ' If Echo is on, send the string to the
       ' textbox on the VB Terminal form.
       If Echo Then
            Form1.Term.Text = Form1.Term.Text _
                & strText & Chr(13)
        End If
    End If
End Sub

' Changed property.
' Read only.
'   Returns True if there is data waiting in the
'   comm port buffer.
'   False if not.
Property Get Changed() As Boolean
Attribute Changed.VB_Description = "Returns True if there is data waiting in the receive buffer"
    If Form1.MSComm1.InBufferCount <> 0 Then
        Changed = True
    Else
        Changed = False
    End If
End Property

' Text property
' Read only.
'   Returns the text waiting in the comm port
'   input buffer. Display the text in the VB
'   Terminal window if Echo is on.
Property Get Text() As String
    ' Set InputLen to 0 so all data is retrieved.
    Form1.MSComm1.InputLen = 0
    ' Get the data.
    Text = Form1.MSComm1.Input
    ' If Echo is on, display the data in the
    ' Terminal window.
    Form1.Term.Text = Form1.Term.Text _
                & Text
End Property

' TrapText property
' Read/write
'   True turns on trapping -- Text property
'   returns the text from the comm port.
'   False turns off trapping -- data received
'   from the comm port is passed through to the
'   terminal window via the OnComm event.
Property Let TrapText(bSetting As Boolean)
    ' If True, set to the current buffer size.
    If bSetting Then
        Form1.MSComm1.RThreshold = Form1.MSComm1.InBufferSize
    Else
        Form1.MSComm1.RThreshold = 0
    End If
End Property

Property Get TrapText() As Boolean
    If Form1.MSComm1.RThreshold <> 0 Then
        TrapText = True
    Else
        TrapText = False
    End If
End Property
