lil_Is -4 Newbie Poster

Hi all,
I have a problem on sending the sms. The message can be sent but the receiver did not receive the full message that is being sent. For example, if i sent the message "helooo", the receiver only receives the letter "h". Here is the code that i am using:

Thanks

Imports System.Windows.Forms.Form
Imports System.Text.Encoding
Imports System.Threading
Imports System.IO.Ports

Public Class Form1

Private WithEvents serialPort As New SerialPort
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'---------------Display all the ports name which available-----------'
For i As Integer = 0 To _
My.Computer.Ports.SerialPortNames.Count - 1
cbbCOMPorts.Items.Add( _
My.Computer.Ports.SerialPortNames(i))
Next
End Sub

Private Sub Connect()
If cbbCOMPorts.SelectedIndex <> -1 Then
MessageBox.Show(cbbCOMPorts.Text)
End If
Try
'---configure the various parameters of the serial port---
With serialPort
.PortName = cbbCOMPorts.Text
.BaudRate = 115200
.Parity = IO.Ports.Parity.None
.DataBits = 8
.StopBits = IO.Ports.StopBits.One
'-----set the encoding to Unicode-----
.Encoding = System.Text.Encoding.Unicode
End With
'---open the serial port---
serialPort.Open()
'---update the status of the serial port and
' enable/disable the buttons---
lblShow.Text = serialPort.PortName & " connected."

Catch ex As Exception
MessageBox.Show("you must select an item")
MsgBox(ex.ToString)
End Try
End Sub

Private Sub Disconnect()
Try
'---close the serial port---
serialPort.Close()
'---update the status of the serial port and
' enable/disable the buttons---
lblShow.Text = cbbCOMPorts.Text & " disconnected."
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub

Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click

Connect()
Try
Dim atcCommand As String
atcCommand = "AT+CMGS=" + RichTextBox1.Text
atcCommand = atcCommand & vbCrLf
serialPort.Write(atcCommand) 'enter the mobile number whom you want to send the SMS
serialPort.Write(textBox1.Text & vbCrLf & Chr(26))

While serialPort.BytesToWrite > 0
System.Threading.Thread.Sleep(100)
End While

MsgBox("Message sent")
Catch ex As Exception
MessageBox.Show("There was an error while sending")
'MessageBox.Show(ex.ToString) 'if you have erors
Finally
Disconnect()
End Try

End Sub
End Class

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.