Click here to Skip to main content
15,891,745 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

i have here the code for recieving text from broadbond to vb.net application this is not complete and have errors can you pls send me a runing programme to my email or complete code doing this tnx

VB
Public Class Form1

    Dim inputData As String = ""
    Public Event DataReceived As IO.Ports.SerialDataReceivedEventHandler

    Private Sub Form1_Load(ByVal sender As System.Object, _
                   ByVal e As System.EventArgs) Handles MyBase.Load
        'Set values for some properties
        SerialPort1.PortName = "COM1"
        SerialPort1.BaudRate = 9600
        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
    Private Sub SerialPort1_DataReceived(ByVal sender As System.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

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

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

End Class
Posted
Comments
Gary Roland 17-Jan-13 14:56pm    
what is the error or pls send me the correct code for this


Private Sub SerialPort1_DataReceived(ByVal sender As System.Object, _
ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) _
Handles SerialPort1.DataReceived
Richard C Bishop 17-Jan-13 15:31pm    
What error are you getting? Are you debugging the code? More information is needed in order to provide assistance.

1 solution

He wants to receive data from "broadband". I will assume that it is some port. But in any case it is USB I guess. USB can not be COM1. So basically he does not know which port to open. Program is fine. All OP needs to do is find out which port the modem or the device is connected to and replace COM1 with the port number of that.
 
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