Sarim Ghani

basically i m making a phone dialer, whose work is to dial a phone number using pabx in .net. i hv made it and its working properly when i dial a number in local network. but when i dial a number through pabx(using prefix #1) nothing is happened.i also provide my code following. plz help me to solve this problem.

Imports MSCommLib

Imports System.Windows.Forms

Public Class Form1

Dim MSComm1 As New MSComm

Dim CancelFlag

Dim a As Application

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dial(TextBox1.Text)

End Sub

Private Sub Dial(ByVal Number As String)

Try

Dim DialString As String, FromModem As String, dummy As String

' AT is the Hayes compatible ATTENTION command and is required to send commands to the modem.

' DT means "Dial Tone." The Dial command uses touch tones, as opposed to pulse (DP = Dial Pulse).

' Numbers is the phone number being dialed.

' A semicolon tells the modem to return to command mode after dialing (important).

' A carriage return, vbCr, is required when sending commands to the modem.

DialString = "ATDT" + Number + ";" + vbCr

' Communications port settings.

' Assuming that a mouse is attached to COM1, CommPort is set to 2

MSComm1.CommPort = 1

MSComm1.Settings = "9600,N,8,1"

' Open the communications port.

Try

MSComm1.PortOpen = True

Catch ex As Exception

MsgBox("COM" & MSComm1.CommPort & ": not available. Change the CommPort property to another port.")

Exit Sub

End Try

' Flush the input buffer.

MSComm1.InBufferCount = 0

' Dial the number.

MSComm1.Output = DialString

' Wait for "OK" to come back from the modem.

Do

'dummy = a.DoEvents()

' If there is data in the buffer, then read it.

If MSComm1.InBufferCount Then

FromModem = FromModem + MSComm1.Input

' Check for "OK".

If InStr(FromModem, "OK") Then

' Notify the user to pick up the phone.

Beep()

MsgBox("Please pick up the phone and either press Enter or click OK")

Exit Do

End If

End If

' Did the user choose Cancel

If CancelFlag Then

CancelFlag = False

Exit Do

End If

Loop

' Disconnect the modem.

MSComm1.Output = "ATH" + vbCr

' Close the port.

MSComm1.PortOpen = False

Catch ex As Exception

End Try

End Sub

End Class




Re: .NET Base Class Library problem facing in making a phone dialer from .net

Inbar Gazit - MSFT

This seems more like a PBX/Telephony issue than a .NET issue. Are you sure the prefix is #1 it's typically #9 in most PBXs but I guess it's configurable. Also, is it possible you need to have a delay after the #1 waiting for the external dialing tone before you can dial the rest of the number (Something some phones do for you automatically if you just dial the whole number)






Re: .NET Base Class Library problem facing in making a phone dialer from .net

nobugz

You'll get one character at a time. Store them in a buffer until you get the line terminator (vbLf, probably), then interpret the response. Also consider using the V2.0 SerialPort class rather than the obsolete VB6 MSComm control. It has a ReadLine() method. Use the Windows HyperTerminal applet to make sure everything is okay with the hardware.





Re: .NET Base Class Library problem facing in making a phone dialer from .net

Sarim Ghani

I found my Answer. Just add cumma [ , ] sign after #1 prefix.