Send SMS using VB code

By Emiley J Viewed: 31799 times Emailed: 203 times Printed: 176 times Bookmark and Share



If you are looking for a simple program to send SMS from your PC using VB then here is the code.

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Sub Form_Load()
'Change this with the Baud rate of your modem (The one you use with Hyper Terminal)
MSComm1.Settings="9600,n,8,1"        
' Change this with the port your Modem is attached 
MSComm1.CommPort=1                     
MSComm1.PortOpen=TRUE            

End Sub

Private Sub Command1_Click()
'This line can be removed if your modem will always be in Text Mode...
MSComm1.Output = "AT+CMGF=1" & vbCrLf                          
Sleep 500
'Replace this with your mobile Phone's No.
MSComm1.Output = "AT+CMGS=+91232538538" & vbCrLf       
Sleep 1000
MSComm1.Output = "Hello This is my test message"
Sleep 2000
If InStr(MSComm1.Input, "OK") Then
    MsgBox "Message Send"
Else
    MsgBox "Message Not Send"
End If

End Sub



Comments(9)


1. Plz. help me in getting code to read messages using GSM modem using java.

By: Jaydatta at 2009-04-03 20:58:57
2. i tried with d above code but am getting an error with d MScomm connection. Do i need to add any controls to my code?

By: Aishwarya at 2009-04-05 04:41:17
3. aishwarya.. i also have that error.. have you solve the error for tt?

By: Geok Lin at 2009-04-06 02:26:49
4. Plz tell me the classes to import for this code and the declaration of the Variable MScomm

By: Nitin at 2009-11-10 02:54:50
5. I got error during using above code if There is need of any component for this code then pls declare here


By: Sunil at 2009-12-28 05:22:45
6. Hi, You need to place a control on your form

go to project - component and check Microsoft comm control 6.0

By: Ranjit at 2010-02-09 02:29:40
7. i am try this codeing in vb . i am using nokia n73 .the code has been executed but sms can't send.so plz help me

By: kanyaraj at 2010-02-09 19:10:10
8. I have try this code.
Code has Run succeefully but sms has not send
plz help me


By: Avinash at 2010-06-07 05:38:26
9. Hai.. i tried with d above code but am getting an error with d MScomm connection. Plz tell how to recover the error?


By: muthupandi at 2010-08-17 09:49:23

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:


Enter Code:
The Captcha image

Latest Tutorials

[2009-03-22]Creating List Views in Code using VB.net
[2009-03-22]Creating Tree Views in Code using VB.net
[2009-03-22]Creating Context Menus in Code using VB.net
[2009-03-22]Creating Menus in Code using VB.net
[2009-03-22]Handling Timer Events - and Creating an Alarm Clock in VB.net
[2009-03-16]Send SMS using VB code
[2009-02-27]Creating a Windows Service Installer in VB.net
[2009-02-27]Creating a Windows Service in VB.net
[2009-02-24]DataRow Class in VB.net
[2009-02-24]DataTable Class in VB.net
[2009-02-24]DataSet Class in VB.net
[2009-02-24]OleDbDataAdapter class in VB.net
[2009-02-24]OleDbConnection class in VB.net
[2009-02-22]A tutorial on Chat Server and Chat Client in VB.net
[2009-02-22]Chat Server in VB.net

More Latest News

Most Viewed Articles (in last 30 days)
For Loop in VB.net
Your first VB.NET Crystal Reports - A step by step guide
Using Select Case in VB.net
How to export from DataGridView to excel using VB.net
Send SMS using VB code
While Loop in VB.net
How to send email using VB.NET code
Sub Procedures and Functions in VB.net
If…Else Statements in VB.net
Arrays and Dynamic Arrays in VB.net
Insert cell data in an Excel file using OLEDB in VB.net
Read Data from Excel using OLEDB in VB.NET 2005
The Select Case statement in VB.net
String Split function in VB.net
File stream operations in VB.net
Most Emailed Articles (in last 30 days)
For Loop in VB.net
Send SMS using VB code
If…Else Statements in VB.net
While Loop in VB.net
The Option and Imports Statements in VB .NET
What's New in VB .NET? A comparison of VB vs VB.net
For Each…Next Loop in VB.net
Using Select Case in VB.net
Visual Basic Statements
The Select Case statement in VB.net
Do Loop in VB.net
“Using If with And” and Comparing two integers using If
Data types in VB.net
What is .NET Framework and the Common Language Runtime?
Arrays and Dynamic Arrays in VB.net