Use VB to realize the source code of Caller ID (part)

Source: Internet
Author: User
Tags exit goto integer
Show | source code

The following code is the last time I gave a company

Do the management information system used to achieve caller ID source code.

When I got here, I just deleted something that didn't work.

Let's just see it.

If you are interested, you can send letters to sobigapple@qq.com to communicate with me.

I'm a rookie.

Option Explicit
Const DEBFLG = 1

Public COMx, Beepno, Hangup, Pnloc as Integer

Public Combuf, Comlin as String
Dim h

Private Sub Command1_Click ()

Frmwelcome.visible = False

End Sub


Private Sub Option1_click (Index as Integer)

COMx = Index + 1

Call Init_modem

End Sub

Private Sub Form_Load ()


' Phone number is empty
PhoneNumber = "' To store the phone number from the cat
GetNumber = "' to store the number after removing the area code


With MSCOMM1
. Inbuffersize = 1024
. Inputlen = 0
. Inputmode = 0
. RThreshold = 1
. Rtsenable = True
. Settings = "9600,n,8,1"
. Sthreshold = 0
End With

' Detect serial port

Dim I, C as Integer

COMX = 0

Combuf = ""

Comlin = ""

Beepno = 0

Hangup = 0

On Error GoTo error_form_load

' Detect available serial ports

For C = 1 to 4

If mscomm1.portopen Then mscomm1.portopen = False

Mscomm1.commport = C

If not Mscomm1.portopen Then

Mscomm1.portopen = True
End If

If mscomm1.portopen Then mscomm1.portopen = False

If comx = 0 Then COMx = C

Form_load_1:

Next C

If comx = 0 Then End

On Error GoTo 0

Option1 (COMX-1). Value = True

Exit Sub

Error_form_load:

Option1 (C-1). Enabled = False

Resume form_load_1
Exit Sub

Exit Sub
Why
MsgBox Err.Description
End Sub

' Detect serial port


' Check if modem commands are complete

Private Sub Chk_modem ()
On Error GoTo Why

Dim T as Single

Dim L as Integer

T = Timer

Todo

Combuf = Combuf + mscomm1.input

L = INSTR (1, combuf, "OK")

Loop Until L <> 0 Or timer-t > 1

If L = 0 Then

MsgBox "Port" & COMx & "No modem is found, please choose another port.", vbOKOnly + vbcritical, "Test Modem"

Else
MsgBox "Caller ID has been activated to determine this button, if returned OK, the computer and modem can communicate normally, otherwise, please retry the other port"

End If
Exit Sub
Why:msgbox Err.Description
End Sub

' Serial port receive event handling
Private Sub Mscomm1_oncomm ()
Dim A
Dim b
On Error GoTo Why
Dim Instrdata As String, TM as String
Dim IPos as Integer
Instrdata = mscomm1.input & MSComm1.Input
IPos = InStr (Instrdata, "nmbr=")
' Whether the recording program is opened for the first time, not the next time the cat's return message is not displayed.

If timeopen = 0 Then
MsgBox Instrdata
Timeopen = 54 ' Written anything can be, but 0 can't be,
MsgBox "Congratulations! Caller ID and modem have been successfully set up." ' Success, haha, I have money to earn
Frmwelcome.visible = False
Command2.visible = False
End If
A = INSTR (1, instrdata, "nmbr =", vbTextCompare)
If a <> 0 Then
b = InStr (A, Instrdata, vbcr, vbTextCompare)
PhoneNumber = Mid (Instrdata, A + 7, b-a-7)
Frmreg.show
Else:
End If
Exit Sub
Why
MsgBox Err.Description
End Sub

Private Sub Init_modem ()
On Error GoTo Why

If mscomm1.portopen Then mscomm1.portopen = False

Mscomm1.commport = COMx

If not mscomm1.portopen Then Mscomm1.portopen = True

Mscomm1.output = "At+vcid=1" + vbcr

' Check if modem commands are complete

Call Chk_modem

Mscomm1.output = "Ats0=0" + vbcr
Exit Sub
Why
MsgBox Err.Description

End Sub



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.