Click here to Skip to main content
15,892,480 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
i tried to write coding for when send SMS to get to vb.net application through inbox in USB modem, in this case i have problem is how to AT commands compile with vb.net for example reading and showing on text box on vb.net application.

i have problem with below underlined coding. so anyone experts in this coding please help me.

thank you

VB
Imports System
Imports System.Threading
Imports System.ComponentModel
Imports System.IO.Ports
Public Class Form1
    Private WithEvents SMSPort As SerialPort
    Private SMSThread As Thread
    Private ReadThread As Thread
    Shared _Continue As Boolean = False
    Shared _ContSMS As Boolean = False
    Private _Wait As Boolean = False
    Shared _ReadPort As Boolean = False
    Public Event Sending(ByVal Done As Boolean)
    Public Event DataReceived(ByVal Message As String)
    Public Sub WindowsApplicaton2(ByRef COMMPORT As String)
        SMSPort = New SerialPort
        With SMSPort
            .PortName = COMMPORT
            .BaudRate = 19200
            .Parity = Parity.None
            .DataBits = 8
            .StopBits = StopBits.One
            .Handshake = Handshake.RequestToSend
            .DtrEnable = True
            .RtsEnable = True
            .NewLine = vbCrLf
        End With
    End Sub
    Public Function ReceiveSMS(ByVal textbox1 As TextBox) As Boolean
        SMSPort.WriteLine("AT")
        SMSPort.WriteLine("AT+CMGF=1" & vbCrLf)
        SMSPort.WriteLine("AT+ CNMI=1,1,0,0,0" & vbCrLf)
        SMSPort.WriteLine("AT+CMGR= 10" & vbCrLf)
        textbox1.Text = SMSPort.ReadExisting
        SMSPort.WriteLine("AT+CMGD=")
    End Function
End Class
Posted
Comments
Herman<T>.Instance 1-Aug-11 9:42am    
do you get any errors?
nalin nishantha 13-Sep-11 9:56am    
hi "digimanus" can u help me, if I using usb 3g dongle for this,then i think we can't use COM port then how is it. if u know help me.
nalin nishantha 1-Aug-11 11:42am    
no, but not any new massages shows in text box and notification also not displayed. sms sending successful.

1 solution

Where have you actually OPENED the serial port connection?

Seeing as you are using VB.net, have you looked at My.Computer.Ports.OpenSerialPort

http://msdn.microsoft.com/en-us/library/tf5cds00(v=vs.80).aspx#Y1529[^]

And the serial port class documentation; http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.aspx[^]
 
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