home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Programmer'…arterly (Limited Edition) / Visual_Basic_Programmers_Journal_VB-CD_Quarterly_Limited_Edition_1995.iso / code / ch18code / applicat.cls next >
Encoding:
Text File  |  1994-10-13  |  2.9 KB  |  105 lines

  1. Version 1.0 Class
  2. Attribute VB_Name = "Application"
  3. Attribute VB_Creatable = True
  4. Attribute VB_Exposed = True
  5. Option Explicit
  6.  
  7. ' Dial method -- same as clicking the Dial Phone Number
  8. ' menu item in the user interface.
  9. Sub Dial(Optional PhoneNumber)
  10. Attribute Dial.VB_HelpID = 1100
  11. Attribute Dial.VB_Description = "Dials a phone number."
  12.     If IsMissing(PhoneNumber) Then
  13.         Form1.MDial_Click
  14.     Else
  15.         Form1.DialNumber CStr(PhoneNumber)
  16.     End If
  17. End Sub
  18.  
  19. ' Hangup method -- same as clicking the Hangup Phone menu
  20. ' item in the user interface.
  21. Sub HangUp()
  22.     Form1.MHangup_Click
  23. End Sub
  24.  
  25. ' PortOpen property
  26. ' Read/Write, Boolean
  27. '   True if Comm port is open.
  28. '   False if Comm port is closed.
  29. Property Get PortOpen() As Boolean
  30.     PortOpen = Form1.MSComm1.PortOpen
  31. End Property
  32.  
  33. Property Let PortOpen(bSetting As Boolean)
  34.     Form1.MSComm1.PortOpen = bSetting
  35. End Property
  36.  
  37. ' SendLine method.
  38. ' Sends a command string to the VB Terminal window.
  39. Sub SendLine(strText As String)
  40.     If Form1.MSComm1.PortOpen Then
  41.        ' Send the line to the comm port.
  42.        Form1.MSComm1.Output = strText & Chr(13)
  43.        ' If Echo is on, send the string to the
  44.        ' textbox on the VB Terminal form.
  45.        If Echo Then
  46.             Form1.Term.Text = Form1.Term.Text _
  47.                 & strText & Chr(13)
  48.         End If
  49.     End If
  50. End Sub
  51.  
  52. ' Changed property.
  53. ' Read only.
  54. '   Returns True if there is data waiting in the
  55. '   comm port buffer.
  56. '   False if not.
  57. Property Get Changed() As Boolean
  58. Attribute Changed.VB_Description = "Returns True if there is data waiting in the receive buffer"
  59.     If Form1.MSComm1.InBufferCount <> 0 Then
  60.         Changed = True
  61.     Else
  62.         Changed = False
  63.     End If
  64. End Property
  65.  
  66. ' Text property
  67. ' Read only.
  68. '   Returns the text waiting in the comm port
  69. '   input buffer. Display the text in the VB
  70. '   Terminal window if Echo is on.
  71. Property Get Text() As String
  72.     ' Set InputLen to 0 so all data is retrieved.
  73.     Form1.MSComm1.InputLen = 0
  74.     ' Get the data.
  75.     Text = Form1.MSComm1.Input
  76.     ' If Echo is on, display the data in the
  77.     ' Terminal window.
  78.     Form1.Term.Text = Form1.Term.Text _
  79.                 & Text
  80. End Property
  81.  
  82. ' TrapText property
  83. ' Read/write
  84. '   True turns on trapping -- Text property
  85. '   returns the text from the comm port.
  86. '   False turns off trapping -- data received
  87. '   from the comm port is passed through to the
  88. '   terminal window via the OnComm event.
  89. Property Let TrapText(bSetting As Boolean)
  90.     ' If True, set to the current buffer size.
  91.     If bSetting Then
  92.         Form1.MSComm1.RThreshold = Form1.MSComm1.InBufferSize
  93.     Else
  94.         Form1.MSComm1.RThreshold = 0
  95.     End If
  96. End Property
  97.  
  98. Property Get TrapText() As Boolean
  99.     If Form1.MSComm1.RThreshold <> 0 Then
  100.         TrapText = True
  101.     Else
  102.         TrapText = False
  103.     End If
  104. End Property
  105.