Click here to Skip to main content
15,917,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
sirs,
i have a write timeout error encountered during i press the send button of this program. please help.here's the code:
VB
Imports System
Imports System.IO.Ports
Imports System.Threading

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try

            Dim ports As String() = SerialPort.GetPortNames
            Dim port As String
            For Each port In ports
                CBCOMPORT.Items.Add(port)
            Next port
            CBCOMPORT.SelectedIndex = 0

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    End Sub

    Private Sub BTNconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNconnect.Click
        Try
            With SerialPort1
                .PortName = CBCOMPORT.Text
                .BaudRate = 9600
                .Parity = Parity.None
                .StopBits = StopBits.One
                .Handshake = Handshake.RequestToSend
                .DataBits = 8
                .DtrEnable = True
                .RtsEnable = True
                .NewLine = vbCrLf
                .Open()
            End With
        Catch ex As Exception
            MsgBox(ex.Message)

        End Try

    End Sub

    Private Sub Btnsend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNSEND.Click
        Try

            If SerialPort1.IsOpen Then
                With SerialPort1

                    .Write("AT" & vbCrLf)
                    .Write("AT+CMGF=1" & vbCrLf)
                    .Write("AT+CMGS=" & Chr(34) & TBCPNUM.Text & Chr(34) & vbCrLf)
                    .Write(RTBMESSAGE.Text & Chr(26))
                    MsgBox("SENT MESSAGE")

                End With
            End If

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
      
    End Sub
End Class
Posted
v2

1 solution

Hurray!!! that was a very good idea bro. But i will advice that you try reading the documentation of your GSM MODEM manufacturer because different MODEM interpret AT command (That in your case AT+CMGF=1) differently. Secondly try using Hyper Terminal that comes pre-installed with windows XP to try and write the errors manually then move that (AT Commands) which works for you to your VB.NET code and BOOM you just did it.

Great Work!!!!!!!!!!!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900