Click here to Skip to main content
15,888,802 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i try to send sms by modem prolink phs301 using AT command, port has been detected on my combo box but when i click send button there is nothing happened. sms not deliver to my number
this is my script

What I have tried:

VB.NET
Imports System.IO.Ports
Imports System.Threading.Thread
Public Class Form1
    Private Tunda As Integer
    Private WithEvents COMport As New SerialPort
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        mati()
        For Each COMString As String In My.Computer.Ports.SerialPortNames
            cmbKoneksi.Items.Add(COMString)
        Next
        cmbKoneksi.Sorted = True
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnKirim.Click
        If cmbKoneksi.Text = "" Or tnohp.Text = "" Or tPesan.Text = "" Then
            MsgBox("Silahkan Isi Semua")
        Else
            COMport.PortName = cmbKoneksi.Text
            COMport.BaudRate = 9600
            COMport.WriteTimeout = 300
            Try
                COMport.Open()
                bersih()
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
            ' Sleep(300)   '....tunggu 0.3 second
            Tunda = 300
            Sleep(Tunda)
            Application.DoEvents()
            If COMport.IsOpen Then
                Try
                    COMport.WriteLine("AT+CMGF=1" & Chr(13))
                    Sleep(Tunda)
                    COMport.WriteLine("AT+CMGS=" & Chr(34) & tnohp.Text & Chr(34) & Chr(13))
                    Sleep(Tunda)
                    COMport.WriteLine(tPesan.Text & Chr(26))
                    Sleep(Tunda)
                Catch ex As Exception
                    MsgBox(ex.Message)
                End Try
            Else
                MsgBox("COM port tertutup.")
            End If
            COMport.Close()
        End If

    End Sub
    Sub bersih()
        cmbKoneksi.Text = ""
        tnohp.Clear()
        tPesan.Clear()
        mati()
    End Sub
    Sub mati()
        cmbKoneksi.Enabled = False
        tnohp.Enabled = False
        tPesan.Enabled = False
        btnKirim.Enabled = False
        btnTulisBaru.Enabled = True
    End Sub
    Sub hidup()
        cmbKoneksi.Enabled = True
        tnohp.Enabled = True
        tPesan.Enabled = True
        btnKirim.Enabled = True
        btnTulisBaru.Enabled = False
    End Sub
    Private Sub btnTulisBaru_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnTulisBaru.Click
        hidup()
    End Sub
End Class
Posted

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