How to get the phone number from callerID

  • Thread starter Thread starter Apostolos Doudakmanis
  • Start date Start date
A

Apostolos Doudakmanis

Guest
Hi

i made a program for modem 56K v.92 to detect the incoming calls and return the phone number

Dim WithEvents Modem As New IO.Ports.SerialPort

Public Delegate Sub myDelegate(ByVal buff() As Byte)

Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
Button1.Text = "Open" 'change button's text
Button2.Text = "Send"
ComboBox1.Items.AddRange(IO.Ports.SerialPort.GetPortNames) 'get all serial port names
End Sub

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs) Handles Me.FormClosing
If Button1.Text = "Close" Then Button1.PerformClick() 'if the port is open close it
End Sub

Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Button1.Enabled = False
If Button1.Text = "Open" Then
'open the port
If Not (ComboBox1.SelectedItem Is Nothing) Then
SerialPort1.PortName = ComboBox1.SelectedItem.ToString

With SerialPort1
.BaudRate = 9600
.DataBits = 8
.Parity = IO.Ports.Parity.None
.StopBits = IO.Ports.StopBits.One
.WriteTimeout = 2
.ReadTimeout = 0
End With

Try
SerialPort1.Open() 'try open
Button1.Text = "Close" 'opened
Catch ex As Exception
MsgBox("Port did not open")
End Try

End If
Else
'close the port
If SerialPort1.IsOpen Then SerialPort1.Close()
Button1.Text = "Open"
End If
Button1.Enabled = True
End Sub

Private Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
Try
SerialPort1.Write("AT+VCID=1" & vbCr) 'should return OK AT#CID=1 or AT+VCID=1
Catch ex As Exception
Debug.WriteLine(ex.InnerException)
End Try
End Sub

Private Sub DataReceived(ByVal sender As Object, ByVal e As IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
If SerialPort1.BytesToRead > 0 Then 'are there bytes to read, s/b
Dim buff(SerialPort1.BytesToRead - 1) As Byte 'get a buffer to hold bytes

SerialPort1.Read(buff, 0, buff.Length) 'read the bytes
Me.BeginInvoke(New myDelegate(AddressOf SerialPortDelegate), buff)
End If
End Sub

Public Sub SerialPortDelegate(ByVal buff() As Byte)
RichTextBox1.AppendText(System.Text.Encoding.ASCII.GetString(buff, 0, buff.Length))
RichTextBox1.AppendText(SerialPort1.ReadExisting)
End Sub

When i have a incoming call the programm write the "RING", but don't write the phone number.

I don't know if i forget something to write in the program

Continue reading...
 
Back
Top