Send SMS using VB code
By Emiley J Viewed: 31799 times Emailed: 203 times Printed: 176 times
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. |
| 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? |
| 3. | aishwarya.. i also have that error.. have you solve the error for tt? |
| 4. | Plz tell me the classes to import for this code and the declaration of the Variable MScomm |
| 5. | I got error during using above code if There is need of any component for this code then pls declare here |
| 6. | Hi, You need to place a control on your form |
| 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 |
| 8. | I have try this code. |
| 9. | Hai.. i tried with d above code but am getting an error with d MScomm connection. Plz tell how to recover the error? |
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 |
Most Viewed Articles (in last 30 days)

