Imports System Imports System.IO.Ports Imports System.Threading Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try Dim ports As String() = SerialPort.GetPortNames Dim port As String For Each port In ports CBCOMPORT.Items.Add(port) Next port CBCOMPORT.SelectedIndex = 0 Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub BTNconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNconnect.Click Try With SerialPort1 .PortName = CBCOMPORT.Text .BaudRate = 9600 .Parity = Parity.None .StopBits = StopBits.One .Handshake = Handshake.RequestToSend .DataBits = 8 .DtrEnable = True .RtsEnable = True .NewLine = vbCrLf .Open() End With Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub Btnsend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNSEND.Click Try If SerialPort1.IsOpen Then With SerialPort1 .Write("AT" & vbCrLf) .Write("AT+CMGF=1" & vbCrLf) .Write("AT+CMGS=" & Chr(34) & TBCPNUM.Text & Chr(34) & vbCrLf) .Write(RTBMESSAGE.Text & Chr(26)) MsgBox("SENT MESSAGE") End With End If Catch ex As Exception MsgBox(ex.Message) End Try End Sub End Class
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)