2 Replies - 4280 Views - Last Post: 08 August 2012 - 07:51 PM Rate Topic: -----

#1 ManishLad2009  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 30-December 10

SEND AND REC. SMS VIA GSM MODEM IN VB.NET

Posted 06 January 2011 - 03:28 AM

Hi all
I want to send SMS Via GSM Modem from vb.net application
I write code
But it is not working .
plz give me way where i am wrong

Here is Code below :

Public Class Form1
Private SMSEngine As SMSCOMMS

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        SMSEngine.Open() 'open the port
        SMSEngine.SendSMS() 
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 = 19200
            .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) 
            SMSPort.WriteLine("AT+CSCA=""+919822078000""" & vbCrLf) 
            SMSPort.WriteLine("AT+CMGS=  + TextBox1.text + " & vbCrLf) 
            _ContSMS = False
            SMSPort.WriteLine("+ TextBox1.text +" & vbCrLf & Chr(26)) 
            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


This post has been edited by no2pencil: 06 January 2011 - 03:31 AM
Reason for edit:: Added code tags


Is This A Good Question/Topic? 0
  • +

Replies To: SEND AND REC. SMS VIA GSM MODEM IN VB.NET

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5667
  • View blog
  • Posts: 22,511
  • Joined: 23-August 08

Re: SEND AND REC. SMS VIA GSM MODEM IN VB.NET

Posted 06 January 2011 - 05:24 AM

Not working HOW??? Please be specific, don't just dump code and say "it's not working".
Was This Post Helpful? 0
  • +
  • -

#3 jeiem  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 16-September 08

Re: SEND AND REC. SMS VIA GSM MODEM IN VB.NET

Posted 08 August 2012 - 07:51 PM

View PostJackOfAllTrades, on 06 January 2011 - 05:24 AM, said:

Not working HOW??? Please be specific, don't just dump code and say "it's not working".


am working around this code and so other examples and am getting stuck on this error:

<error> object reference not set to an instance of an object </error> at run time
how should i initialize/declare the class to reference the class in the form.
2. would the code to send the form just work on the form instead of using class if the former isntmaking headway
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1