I have a code regarding SMS sending ,but the issue is its not working i have tried to change the buad rate and com port but still not working.Please suggest me what is the reason ?

Imports System
Imports System.Threading
Imports System.ComponentModel
Imports System.IO.Ports

Public Class Form1
    'connect your mobile/GSM modem to PC,
    'then go in device manager and check under ports which COM port has been slected
    'if say com1 is there then put com2 in following statement
    Dim SMSEngine As New SMSCOMMS("COM4")
    Dim i As Integer
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        SMSEngine.Open() 'open the port
        SMSEngine.SendSMS() 'send the SMS

    End Sub

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

    End Sub
End Class
Public Class SMSCOMMS
    Private WithEvents SMSPort As SerialPort
    Private SMSThread As Thread
    Private ReadThread As Thread
    Shared _Continue As Boolean = False
    Shared _ContSMS As Boolean = False
    Private _Wait As Boolean = False
    Shared _ReadPort As Boolean = False
    Public Event Sending(ByVal Done As Boolean)
    Public Event DataReceived(ByVal Message As String)

    Public Sub New(ByRef COMMPORT As String)
        'initialize all values
        SMSPort = New SerialPort
        With SMSPort
            .PortName = COMMPORT
            .BaudRate = 115200
            .Parity = Parity.None
            .DataBits = 8
            .StopBits = StopBits.One
            .Handshake = Handshake.RequestToSend
            .DtrEnable = True
            .RtsEnable = True
            .NewLine = vbCrLf
        End With
    End Sub
    Public Function SendSMS() As Boolean
        If SMSPort.IsOpen = True Then
            'sending AT commands
            SMSPort.WriteLine("AT")
            SMSPort.WriteLine("AT+CMGF=1" & vbCrLf) 'set command message format to text mode(1)
            'SMSPort.WriteLine("AT+CSCA=""+923330005150""" & vbCrLf) 'set service center address (which varies for service providers (idea, airtel))
            SMSPort.WriteLine("AT+CMGS=  + TextBox1.text + " & vbCrLf) ' enter the mobile number whom you want to send the SMS
            _ContSMS = False
            SMSPort.WriteLine("+ TextBox1.text +" & vbCrLf & Chr(26)) 'SMS sending
            MessageBox.Show(":send")
            SMSPort.Close()
        End If
    End Function

    Public Sub Open()
        If Not (SMSPort.IsOpen = True) Then
            SMSPort.Open()
        End If
    End Sub

    Public Sub Close()
        If SMSPort.IsOpen = True Then
            SMSPort.Close()
        End If
    End Sub
End Class

Before you code, use a terminal app and issue commands to make sure your strings and responses match your code. You may have to put a serial port sniffer (I use this old RS232 cable to another PC or two to watch the data) to see what's up.

I don't know if you did the first before coding.

Your codes are quite right. A little bit change is needed. You can use 9600 as baudrate. And a little change is needed in the function SendSMS().
codes are following

If SMSPort.IsOpen() Then
   SMSPort.Write("AT" & vbCrLf)
   SMSPort.Write("AT+CMGF=1" & vbCrLf)
   SMSPort.Write("AT+CMGS=" & Chr(34) & phoneNumBox.Text & Chr(34) & vbCrLf)
   SMSPort.Write(message & Chr(26))
   MessageBox.Show(":send")
   SMSPort.Close()
Else
   MsgBox("Port not available")
End If

Hope it can help you

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.