Solved

Use MSComm Control to detect the phone ring...

Posted on 1998-04-10
2
936 Views
Last Modified: 2010-05-18
I would like to use the MSComm to detect the phone ringing. How do I do it? Like sample code, please.
Thanks in advance
0
Comment
Question by:AmyH111
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
Dalin earned 200 total points
ID: 1460918
AmyH111,
See if this is waht you are after:

Start a new project
Drop a command button, Name it CmdOK
Drop a MSComm control
Drop a timer


Option Explicit

Private Declare Function SetWindowPos% Lib "user" (ByVal win%, ByVal awin%, ByVal xp%, ByVal yp%, ByVal xs%, ByVal ys%, ByVal flags%)

Private Sub Comm1_OnComm()
Static ReceiveBuffer As String
Dim Position As Integer
    ReceiveBuffer = ReceiveBuffer & Comm1.Input
    Position = InStr(ReceiveBuffer, Chr$(13) & Chr$(10))
    If Position Then                         'Parse the message
        If InStr(ReceiveBuffer, "RING") Then PopUpForm
        ReceiveBuffer = Mid$(ReceiveBuffer, Position + 1)
        If Len(ReceiveBuffer) Then Comm1_OnComm  'recurse if required
    End If
End Sub

Private Sub Form_Load()
Dim I As Integer
    On Error Resume Next
    Comm1.PortOpen = True
    If Err Then
        MsgBox "The selected port is not available"
        Unload Me
    End If
    Comm1.RTSEnable = True
    Comm1.RThreshold = 1
    Comm1.Output = "ATV1Q0S0=0" & Chr$(13)
    I = SetWindowPos(Me.hWnd, -2, 0, 0, 0, 0, 3)    'not On Top
    Me.WindowState = 1
End Sub

Private Sub OKbutton_Click()
Dim I As Integer
    I = SetWindowPos(Me.hWnd, -2, 0, 0, 0, 0, 3)
    Me.WindowState = 1
    DoEvents
End Sub

Private Sub PopUpForm()
Dim I As Integer
    Me.WindowState = 0
    I = SetWindowPos(Me.hWnd, -1, 0, 0, 0, 0, 3)  'Set On Top
    Me.Refresh
    DoEvents
    Beep
    MsgBox "Ring....", vbOKOnly, "ring"
    Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
    Timer1.Enabled = False
    OKbutton_Click
End Sub


When the phone ring, the form will come out.
click of, the form minimized.

Good luck
Dalin
0
 

Author Comment

by:AmyH111
ID: 1460919
Thanks
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month10 days, 15 hours left to enroll

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question