Click here to Skip to main content
11,493,948 members (63,387 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
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

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 17-Jan-13 9:54am
Comments
Gary Roland at 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
richcb at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 448
1 F-ES Sitecore 229
2 Nakul Chaudhari 225
3 OriginalGriff 225
4 CPallini 215
0 Sergey Alexandrovich Kryukov 10,237
1 OriginalGriff 8,730
2 Sascha Lefèvre 3,664
3 Maciej Los 3,392
4 Richard Deeming 2,500


Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 21 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100