Link to home
Start Free TrialLog in
Avatar of jjrr007
jjrr007

asked on

Add features to VB code

Hi,

I am working with VB.NET code that is shown at:
http://www.developerfusion.co.uk/show/194

I need to add two features to this code:
1.  Hang-up the phone if 8 rings occur
2. If the phone is picked up, it will wait 3 seconds.

Please post the additional code here.  I am happy to answer any questions you have.

Thank you.
Avatar of Erick37
Erick37
Flag of United States of America image

1)

Not sure how to detect the number of rings, but you can set a timeout period.  This will exit the loop after 15 seconds...

Dim dt As Date
dt = Now
   
Do While DateDiff("s", dt, Now) < 15
    dummy = DoEvents()
    '...
You did say .NET

Dim dt As Date = Date.Now

Do While DateDiff(DateInterval.Second, dt, Date.Now) < 15
Avatar of jjrr007
jjrr007

ASKER

Yes it is .NET

The timeout period should only occur if the phone is picked up.  I need the code for that event.  After three seconds from the time the phone is picked up.  And to hang up after 8 rings.

Thank you.
Avatar of jjrr007

ASKER

I had an error in my last post.  The last two post should read:

Yes, it is .NET.

In regards to the code, the timeout period should only occur if the phone is picked up.  I need the code for that event and after eight rings the line should be hung up.

Thank you
I'm not aware of any way to have the MSComm control listen for rings on an outgoing call.  I believe you will have to setup the modem to do things like that using the AT commands.  For example:

To instruct the modem to dial a number, listen for ringing, and then wait for up to fifty seconds for a 5 second silence (you can change the wait time with register S7) before proceeding you could use the following command line:

ATDT876-5555@ 5678 <Enter>


Reference:
http://www.zoltrix.com/support_html/modem/USEMODEM.HTM
Avatar of jjrr007

ASKER

Hey Erick37,

With regards to your link, can I use the commands listed in your link within VB Code.  Do I just list it directly?

Kindly advise.  Thank you.
In the code you referenced above:

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

Is the command sent to the modem.  You would need to modify that to reflect the new dial string you want to send.

DialString = "ATDT" + Number + "@ 5678" + vbCr '<~~~Maybe this?


I cannot test these commands because I do not have a modem at this location.
Avatar of jjrr007

ASKER

Erick,

Thanks a lot for your posts.  I learned a lot.  I didn't know the at commands were related to this.  After looking at your link, I am not sure what this means:

"silence (you can change the wait time with register S7)?" How do I change that setting?
Avatar of jjrr007

ASKER

Another idea, would be to change the code at this point:

 If InStr(FromModem, "OK") Then

Instead of OK, maybe their is something for a pick-up or if 8 rings...

This seems like a more likely place for the solution.  

What would I use instead of OK?
The wait time is stored in a register called S7
I think the default is 5 seconds
You can change it using the command ATS7=10 for 10 seconds
Avatar of jjrr007

ASKER

OK,

So I will use this line to wait for a silence after the answer:
DialString = "ATDT" + Number +"@" + ";" + vbCr

Then how about to check if their is no answer after 8 rings.  I am pretty sure I can replace the "OK" below with some other word/characters:


 If InStr(FromModem, "OK") Then

Do you know what that would be?
Avatar of jjrr007

ASKER

Eric or Other Professional,

So would this command do the second part of the question?:

DialString = "ATS7=3" +";" +vbCr + "ATDT" + Number +"@" + ";" + vbCr

Would about the first part of the question?
ASKER CERTIFIED SOLUTION
Avatar of Erick37
Erick37
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jjrr007

ASKER

Erick37

Are you saying that I should use a command like ATS7=10  (or other appropriate setting) as the dial command? So it will look like:

DialString = "ATS7=3" + Number + ";" + vbCr

Or should they be separate commands?