shyhigh2002 0 Newbie Poster

Can anyone help me on how can i read data from gsm modem in vb.net?

As in like when the gsm modem receive a sms, it will auto detect and read data from gsm modem and display it on a textbox in a sms application.

here is the code I do:

Imports System
Imports System.Windows.Forms
Imports System.IO.Ports
Imports System.Threading

Public Class sms
Dim buffer As Char()
Dim returnValue As Integer

'Public Sub Read()
'Dim message As String
' Do
' message = SerialPort1.ReadLine()
' Select Case message
' Case My.Settings.hello
' TextBox1.Text = "hello"
' End Select
' Loop
' End Sub

Private Sub sms_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Dim i As Integer

SerialPort1.PortName = "COM6"
SerialPort1.BaudRate = 9600
SerialPort1.Parity = Parity.None
SerialPort1.DataBits = 8
SerialPort1.StopBits = StopBits.One
SerialPort1.Handshake = Handshake.None

SerialPort1.Open()
TextBox1.Text = "Port Open"
SerialPort1.Write("AT")
TextBox1.Text = "Write"

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
returnValue = SerialPort1.Read(buffer, 0, 2)
TextBox1.Text = buffer(0)
End Sub
End Class

Thanks in advance!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.