Click here to Skip to main content
15,888,293 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
1.The below written codes works only if the button is clicked twice.
2.The message is send along with AT command and phonenumber. eg."AT+CMGS"9430011111" hii there!!!
Imports System.IO.Ports

Public Class Form1
    Shared _Continue As Boolean = False
    Shared _ContSMS As Boolean = False

    Dim SerialPort1 As New System.IO.Ports.SerialPort()
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        SerialPort1.PortName = "COM3"
        SerialPort1.BaudRate = 115200
        SerialPort1.Parity = Parity.None
        SerialPort1.StopBits = StopBits.One
        SerialPort1.DataBits = 8
        SerialPort1.Handshake = Handshake.RequestToSend
        SerialPort1.DtrEnable = True
        SerialPort1.RtsEnable = True

        SerialPort1.NewLine = vbCrLf

        SerialPort1.Open()
    End Sub

    Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


        If SerialPort1.IsOpen() Then
           


            
            SerialPort1.Write("AT+CMGS=" & """" & "9430011111" & """" & vbCrLf &"hii there!!!" & Chr(26))
            
        End If



       

    End Sub



End Class
Posted

have you've tried send AT command using the hypertermal? as i noticed you need two user action to send sms using hypertermal.. which is AT+CMGS="desired number"(first user action) then type a message then press CTRL+Z to send it... so this is what happen to your button action... the first click was to send the command AT+CMGS and the second click was for the CTRL+Z to send it...

1 more thing when you receive the message the at command was include into the sent message... here is my answer code to your problem...

VB
SerialPort1.WriteLine("AT+CMGS=" & """" & "09103434639" & """" & vbCrLf)
            SerialPort1.WriteLine("hii there!!!" & Chr(26))


cheers....
paperjam,ph
 
Share this answer
 
Comments
Ashok19r91d 24-Dec-12 2:09am    
+5
Use SerialPort1.WriteLine instead of SerialPort1.Write
 
Share this answer
 
SerialPort1.WriteLine("AT+CMGS=" + Chr(26) + "09103434639" & + Chr(26)+& vbCrLf)
SerialPort1.WriteLine("hii there!!!" & Chr(26))
Thread.wait(500)
 
Share this answer
 
separate the part for settig receivrr contact and the message and in between include a delay of 3 seconds .by doing that u will even avoid sending the commands as part of message. can contact for a sample in this email fchege20@yahoo.com
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900