Solved

Use MSComm Control to detect the phone ring...

Posted on 1998-04-10
2
932 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
vb6 connector to SQL Server 2 42
Modifying Conditional Format from VBA code 3 84
VB6 ListBox Question 4 62
adding "ungroup sheets" to existing vbs code 5 75
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

734 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