mardi 5 mai 2015

How to read data from usb to serial port converter into textbox using vb.net?

I have an problem in reading data from serial port into text box using vb.net, i just tried a lot till now i didn't get any solutions for that please help me out of this problem! i have one form,button to recieve and textbox to show recieved data! i have used the below function from msdn networks!

Function ReceiveSerialData() As String
    ' Receive strings from a serial port. 
    Dim returnStr As String = ""

    Dim com1 As IO.Ports.SerialPort = Nothing
    com1 = My.Computer.Ports.OpenSerialPort("COM3")
    com1.ReadTimeout = 1000
    Do
        Dim Incoming As String = com1.ReadLine()
        If Incoming Is Nothing Then
            Exit Do
        Else
            returnStr &= Incoming & vbCrLf
        End If
    Loop
    Return returnStr
End Function

after running this code i got output like "The operation has timed out."

i just want to connect weight scale into my vb.net application! i don't know how to do ! i am beginner to this problem! thanks in advance!

Aucun commentaire:

Enregistrer un commentaire