how to do display text message from cellphone to textbox

Posted by Jiggy Degamo on Stack Overflow See other posts from Stack Overflow or by Jiggy Degamo
Published on 2011-01-12T06:38:49Z Indexed on 2011/01/12 6:53 UTC
Read the original article Hit count: 271

Filed under:

I am just making a project automated polling system using sms but i just a beginner of serial communication i have seen a code on the net so i apply it as my guide just a simple text message and display it on the textbox it connects but the provlem is its didn't display on the textbox. here is the code below please help me why it didn't display and please give me a cite that have a tutorial of serial communication using vb.net

Imports System.IO.Ports

Public Class Form1
    Dim inputData As String = ""
    Private WithEvents serialPort1 As New IO.Ports.SerialPort
    Public Event DataReceived As IO.Ports.SerialDataReceivedEventHandler

    Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        ' Close the Serial Port
        serialPort1.Close()
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Set values for some properties
        serialPort1.PortName = "COM10"
        serialPort1.BaudRate = 2400
        SerialPort1.Parity = IO.Ports.Parity.None
        SerialPort1.DataBits = 8
        SerialPort1.StopBits = IO.Ports.StopBits.One
        SerialPort1.Handshake = IO.Ports.Handshake.None
        SerialPort1.RtsEnable = True

        ' Open the Serial Port
        SerialPort1.Open()

        'Writes data to the Serial Port output buffer 
        If SerialPort1.IsOpen = True Then
            SerialPort1.Write("MicroCommand")
        End If

    End Sub
    ' Receive data from the Serial Port

    'Show received data on UI controls and do something
    Public Sub DoUpdate()
        TextBox1.Text = TextBox1.Text & inputData

    End Sub




    Private Sub serialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles serialPort1.DataReceived
        inputData = serialPort1.ReadExisting 'or serialPort1.ReadLine
        Me.Invoke(New EventHandler(AddressOf DoUpdate))

    End Sub
End Class

© Stack Overflow or respective owner

Related posts about vb.net