Community discussion forum

VB Function for Sending SMS

Tags: db, vb6 India
  • 3 years ago

    Application for Sending SMS (PC-MODEM-MOBILE,or PC-MOBILE-MOBILE) for VB developers.


    This is for all the friends in the forum who really use it for purpose.


  • 3 years ago

    Form - frmmain


    MSCOMM control - Name it as gsmcom
    Button--Name it as cmdsend
    Textbox controls 2no's - txtmobilenumber.text
                                    - txtmessage.text





    Copy the following lines of code (FUNCTION) to your form code



    Function sendSMS(MobileNumber As String,MessageData as string)


    Dim smsdata$
    Dim buffe$


    smsdata = "AT+CMGS = " & MobileNumber & Chr$(13)


    gsmcon.Output = smsdata


    'Write a function for delay(1 second)


    gsmcon.Output = MessageData & Chr$(26)


    Do
       DoEvents


       buffe = buffe & gsmcon.Input


    If InStr(buffe, "ERROR" & vbCrLf) Then
       Msgbox "Message Delivery Failed"
     
    End If
    Exit do


    Loop Until InStr(buffe, "OK" & vbCrLf)


    If InStr(buffe, "OK" & vbCrLf) Then
       Msgbox "Message Sent"
      buffe = ""
    End If


    End Function




    How to Run.


    1.Open port (form_load event)   -------------        gsmcom.portopen = true


    2.
    Call the function sendSMS in button click event.
    Pass parameters. eg:  sendSMS(txtmobilenumber.text,txtmessage.text)



  • 3 years ago
    form_load
  • 3 years ago

    hi krishna,
    i have done the same thing.  i am using nokia 9500 communicator connected to my pc through USB.  nothing is happening for me. please help


    regards


    Ratra

  • 3 years ago

    Hi Ratra,


    Please check the virtual comport(Comm 1, Comm2,etc,etc).


    Rgards
    krishna

  • 1 year ago

    hello kisna..

    i'm reall need ur help..i'm out of time now..i'm really newbie in this fields and also in vb 6..can u give me full coding of  this form and if i want to get phone number from my database,what i need to change to make it work out.....if this coding is work with nokia 7610....plz help me..i need to present this system on next tuesday(8/4/2008)...i really hope u can help me..thank u so much...

  • 1 year ago

    helo kisna....if that i need to call any .DLL file or library to run this program.which line of coding that i need to change based on which port that i use,,,,,,if i want to sent my word,where can i define it...can u explain it to my..u can email me at anatasia_et84@yahoo.com or ym me at crysalis_berry@yahoo..tq

  • 1 year ago
    wow! thanks kisna! surely this would held alot.. would retrieving received messages be that same? been trying to retrieve using AT+CNMI command but it returns an error..
  • 1 year ago
    Hi nice to see you guys using my set of lines, AT+CNMI is used at configuring your modem in reading SMS or Storing SMS on SIM AT+CNMI=2,1,0,0,0 is used to Store SMS in SIm Memory. Use AT+CMGR=1 [used for reading an SMS which is at position 1] hope it works out this time. Bye Kisna

Post a reply

Enter your message below

Sign in or Join us (it's free).

Want to stay in touch with what's going on? Follow us on twitter!