MSCOMM.OCX and Exception from HRESULT: 0x800A1F52

  • Thread starter =?iso-8859-1?q?Recep_TARAK=C7I?=
  • Start date
?

=?iso-8859-1?q?Recep_TARAK=C7I?=

hi everbody

i am using visual basic 2005. i am write a modem control program and
get callerID value. i am send a AT command to modem.


Dim mscomm1 As New MSCommLib.MSComm

mscomm1.CommPort = 3
mscomm1.PortOpen = True
mscomm1.Output = "AT#CID=1"
mscomm1.Output = "AT%CCID=1"
mscomm1.Output = "AT+VCID=1"
mscomm1.Output = "AT#CC1"
mscomm1.Output = "AT*ID1"

every command return OK or ERROR.

Sub KontrolEt()
'control telephone line
Try
Dim m As String
Dim r As String = TextBox1.Text

m = r.Substring(123, 1)


If m = "0" Then
r = r.Substring(123, 11)
GoTo there
End If

If m = "0" Then

Timer1.Enabled = False
Me.BarButtonItem17.Enabled = True
mscomm1.PortOpen = False

TextBox1.Text = ""
MsgBox("no number")
frmMusteriSec.Show()
Else
r = r.Substring(123, 7)
End If
there:

Timer1.Enabled = False
mscomm1.PortOpen = False

TextBox1.Text = ""

frmSiparisAl.FormShow(1, "", m)

Catch ex As Exception

End Try
End Sub

telephone ring and my program error code : Exception from HRESULT:
0x800A1F52. what is this code. but this code run vb.net 2003 and no
problem
 
D

Dick Grier

Hi,

You should be using the System.IO.Ports namespace, not MSComm.

However, your code will not work for several reasons (which will be true for
MSComm or System.IO.Ports).

1. You must terminate each command to the modem with a carriage return
(vbCr). For example:
mscomm1.Output = "AT#CID=1" & vbCr

2. You MUST wait between commands to the modem, sufficient time for the
modem to process THAT command and to return a result -- the easiest way is
to call a function that looks for that specific modem response (often "OK" &
vbCrLf). If you do not wait, the modem with "ERROR".

The CID results will be available (with appropriate code) via the OnComm
event. You enable OnComm receive events by setting mscomm.RThreshold = 1.
Remember to set RTSEnable = True, also.


--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004.
See www.hardandsoftware.net for details and contact information.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top