Send SMS using GSM modem from your computer. This Example shows you to use AT command to handle the GSM modem.
Try this to send SMS using this example.
1- Insert a form in VB project
2- Insert textbox (txtMsg,txtDestinationNumber)
3- Insert command button (Command1)
4- Insert a MSComm1
5- Connect your mobile phone in computer with datacable
Private Sub Command1_Click() Call SENDSMS End Sub Sub SENDSMS() On Error GoTo Errr: If MsgBox("Are you sure to send SMS Message", vbYesNo) = vbNo Then Exit Sub End If
' Set up the communications port MSComm1.CommPort = 5 ' Com Port 5
' Set for 9600 baud, no parity, 8 data, and 1 stop bit. MSComm1.Settings = "9600,N,8,1" MSComm1.InputLen = 0 MSComm1.PortOpen = True MSComm1.Output = "AT" & Chr$(13)
' Set up the phone for a text message MSComm1.Output = "AT+CMGF=1" & Chr$(13) MSComm1.Output = "AT+CMGS= " & Chr(34) & txtDestinationNumber.Text & Chr(34) & Chr$(13) & Chr(10) MSComm1.Output = txtMsg.Text & Chr$(26) MSComm1.PortOpen = False MsgBox "Message Sent successfully" Exit Sub
Errr:
MsgBox Err.Description & Err.Number, vbExclamation End Sub
Filed under: Send SMS using AT command | Tagged: 1, 8, AT command, AT command to send sms, AT Commands, AT+CMGF=1, AT+CMGR, GSM modem, How to send SMS using AT commands, MSComm1, MSComm1.PortOpen = True, MSComm1.Settings = "9600, N, send SMS, SMS from GSM modem, Use MScomm library, VB code to send sms, VB Tricks and Tips, VB6 code to send sms, Visual basic code to send sms, Visual Basic Tips, Visual Basic Tricks | 6 Comments »