Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have an old code (VB6) to test po

Status
Not open for further replies.

ridifvx

Programmer
Apr 10, 2003
34
ID
I have an old code (VB6) to test port com1 which is connected with my phonecell.. i upgraded to VB.NET using upgrade wizards and my code change into like this

Code:
Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click
        Dim buffer As String
        On Error GoTo err_handler
        With AxMSComm1 'oldname mscomm1
            .CommPort = 1
            .Settings = "57600,N,8,1"
            .InputLen = 0
            .PortOpen = True
        End With
        Dim waktu As Date
        waktu = Now
        Do
            AxMSComm1.Output = "ATE1" & Chr(13)
            Do
                buffer = buffer & AxMSComm1.Input
            Loop Until InStr(buffer, "OK") Or InStr(buffer, "ERROR") Or Now > DateAdd(Microsoft.VisualBasic.DateInterval.Second, 10, waktu)
        Loop Until InStr(buffer, "OK") Or Now > DateAdd(Microsoft.VisualBasic.DateInterval.Second, 10, waktu)
        AxMSComm1.PortOpen = False
        
AxMSComm1 = Nothing
        If InStr(buffer, "OK") Then
            MsgBox("Kondisi port OK.")'port is ok
        Else
            MsgBox("Port tidak dapat digunakan saatini.") 'port is bad 
End If

err_handler:
If Err.Number = 8002 Or Err.Number = 8005  Then 
AxMSComm1 = Nothing
	End Sub
the projects is compiled succesfull but cannot run always fail (port is bad)

any suggestion please ?
BTW anyone has *.dll to send sms
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top