home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l405 / 1.ddi / DIALER.FR_ / DIALER.bin (.txt)
Encoding:
Visual Basic Form  |  1993-04-28  |  5.4 KB  |  168 lines

  1. VERSION 2.00
  2. Begin Form DIALER 
  3.    Caption         =   "MSComm Phone Dialer"
  4.    ClientHeight    =   2205
  5.    ClientLeft      =   2865
  6.    ClientTop       =   1500
  7.    ClientWidth     =   3270
  8.    Height          =   2610
  9.    Left            =   2805
  10.    LinkTopic       =   "Form2"
  11.    ScaleHeight     =   2205
  12.    ScaleWidth      =   3270
  13.    Top             =   1155
  14.    Width           =   3390
  15.    Begin CommandButton CancelButton 
  16.       Caption         =   "Cancel"
  17.       Enabled         =   0   'False
  18.       Height          =   348
  19.       Left            =   1200
  20.       TabIndex        =   4
  21.       Top             =   1728
  22.       Width           =   852
  23.    End
  24.    Begin CommandButton QuitButton 
  25.       Cancel          =   -1  'True
  26.       Caption         =   "Quit"
  27.       Height          =   348
  28.       Left            =   2160
  29.       TabIndex        =   2
  30.       Top             =   1728
  31.       Width           =   852
  32.    End
  33.    Begin MSComm Comm1 
  34.       Interval        =   1000
  35.       Left            =   0
  36.       Top             =   0
  37.    End
  38.    Begin CommandButton DialButton 
  39.       Caption         =   "Dial"
  40.       Default         =   -1  'True
  41.       Height          =   348
  42.       Left            =   240
  43.       TabIndex        =   1
  44.       Top             =   1728
  45.       Width           =   852
  46.    End
  47.    Begin ListBox List1 
  48.       Height          =   1005
  49.       Left            =   240
  50.       TabIndex        =   0
  51.       Top             =   240
  52.       Width           =   2775
  53.    End
  54.    Begin Label Status 
  55.       BorderStyle     =   1  'Fixed Single
  56.       Caption         =   "Select a party to call"
  57.       Height          =   252
  58.       Left            =   240
  59.       TabIndex        =   3
  60.       Top             =   1296
  61.       Width           =   2772
  62.    End
  63. '--------------------------------------------------------
  64. '-- DIALER.FRM
  65. '   Copyright (c) 1993 Crescent Software, Inc.
  66. '   by Carl Franklin
  67. '   Demonstrates how to dial phone numbers with a modem.
  68. '   In order for this program to work, your telephone and
  69. '   modem must be connected to the same phone line.
  70. '--------------------------------------------------------
  71. Option Explicit
  72. DefInt A-Z
  73. '-- Phone numbers are stored here
  74. Dim PhoneNumbers$()
  75. '-- This flag is set when cancel is pressed
  76. Dim CancelFlag
  77. Sub CancelButton_Click ()
  78.     '-- CancelFlag tells the Dial routine to exit
  79.     CancelFlag = True
  80.     CancelButton.Enabled = False
  81. End Sub
  82. Sub Dial (Number$)
  83.     Dim DialString$, FromModem$, dummy
  84.     '--- AT is the Hayes compatible ATTENTION command an is required to send commands to the modem.
  85.     '--- DT means "Dial Tone" - The Dial command, using touch tones as opposed to pulse (DP = Dial Pulse)
  86.     '--- PhoneNumbers$(Index) is the phone number of the person you're dialing
  87.     '--- A semicolon tells the modem to return to command mode after dialing (important)
  88.     '--- A Carriage return, Chr$(13), is required when sending commands to the modem.
  89.     DialString$ = "ATDT" + Number$ + ";" + Chr$(13)
  90.     '-- Comm port settings
  91.     Comm1.Settings = "300,N,8,1"
  92.     '-- Open the comm port
  93.     On Error Resume Next
  94.     Comm1.PortOpen = True
  95.     If Err Then
  96.        MsgBox "COM1: not available. Change the CommPort property to another port."
  97.        Exit Sub
  98.     End If
  99.     '-- Flush the input buffer
  100.     Comm1.InBufferCount = 0
  101.     '-- Dial the number
  102.     Comm1.Output = DialString$
  103.     '-- Wait for "OK" to come back from the modem
  104.     Do
  105.        dummy = DoEvents()
  106.        '-- If there is data in the buffer, then read it.
  107.        If Comm1.InBufferCount Then
  108.           FromModem$ = FromModem$ + Comm1.Input
  109.           '-- Check for "OK"
  110.           If InStr(FromModem$, "OK") Then
  111.              '-- Notify the user to pick up the phone
  112.              Beep
  113.              MsgBox "Please pick up the phone and either press Enter, or click OK"
  114.              Exit Do
  115.           End If
  116.        End If
  117.         
  118.        '-- Was Cancel pressed?
  119.        If CancelFlag Then
  120.           CancelFlag = False
  121.           Exit Do
  122.        End If
  123.     Loop
  124.     '-- Disconnect the modem
  125.     Comm1.Output = "ATH" + Chr$(13)
  126.     '-- Close the port
  127.     Comm1.PortOpen = False
  128. End Sub
  129. Sub DialButton_Click ()
  130.     Dim Number$, Temp$
  131.     DialButton.Enabled = False
  132.     QuitButton.Enabled = False
  133.     CancelButton.Enabled = True
  134.     '-- Get the number to dial
  135.     Number$ = PhoneNumbers$(List1.ListIndex)
  136.     Temp$ = Status
  137.     Status = "Dialing - " + Number$
  138.     '-- Dial the selected phone number
  139.     Dial Number$
  140.     DialButton.Enabled = True
  141.     QuitButton.Enabled = True
  142.     CancelButton.Enabled = False
  143.     Status = Temp$
  144. End Sub
  145. Sub Form_Load ()
  146.     '-- Setting InputLen to 0 tells MSComm to read the entire
  147.     '   contents of the input buffer when the Input property
  148.     '   is used.
  149.     Comm1.InputLen = 0
  150.     Dialer.Show
  151.     '-- Load the list box with names
  152.     List1.AddItem "Information"
  153.     List1.AddItem "800 Information"
  154.     '-- Phone numbers
  155.     ReDim PhoneNumbers$(0 To List1.ListCount - 1)
  156.     PhoneNumbers$(0) = "1-555-1212"
  157.     PhoneNumbers$(1) = "1-800-555-1212"
  158.     '-- Select the first name as default
  159.     List1.ListIndex = 0
  160. End Sub
  161. Sub List1_DblClick ()
  162.     '-- Invoke the Dial button
  163.     DialButton_Click
  164. End Sub
  165. Sub QuitButton_Click ()
  166.     End
  167. End Sub
  168.