receive data from serial comm and display on VB 6.0 textbox

Discussion in 'Programmer's Corner' started by bubblysush, May 18, 2012.

  1. bubblysush

    Thread Starter New Member

    May 14, 2012
    3
    0
    Hello allllll :D
    PLZ PLZ PLZ help meeeeeeeee :(

    m using a RFID module which i have programmed, m sending the data to the pc... m able to see the data in the hyperterminal of the system...
    I want to see the same data on my VB 6.0 Form text box.... the data is not display.. this is the code
    Private Sub MSComm1_OnComm()
    Dim strInput As String
    'test for incoming event
    S
     
  2. bubblysush

    Thread Starter New Member

    May 14, 2012
    3
    0
    sorry this is the code

    Private Sub MSComm1_OnComm()
    Dim strInput As String

    'test for incoming event
    Select Case .CommEvent
    Case comEvReceive
    'display incoming event data to displaying textbox
    strInput = MSComm1.Input
    text1.SelText = strInput
    End Select

    End Sub
     
  3. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    I don't use the Seltext property of a textbox, I use the Text property.
    Code ( (Unknown Language)):
    1.  
    2. Private Sub MSComm1_OnComm()
    3.  
    4. if .CommEvent = comEvReceive
    5.     'display incoming event data to displaying textbox
    6.      Text1.Text = MSComm1.Input
    7. endif
    8.  
    9. End Sub
    I may be missing some other things (like emptying the receive buffer) as I don't have VB6 anymore.

    <sigh> I need to dig that CD up.
     
  4. BMorse

    Senior Member

    Sep 26, 2009
    2,675
    234
    Code ( (Unknown Language)):
    1. Private Sub MSComm1_OnComm()  
    2. if .CommEvent = comEvReceive     'display incoming event data to displaying textbox      
    3. [COLOR=Red]Text1.Text = Text1.text & MSComm1.Input[/COLOR]
    4. endif  
    5. End Sub
    6.  
    Try appending the incoming data to the textbox text instead of overwriting it with every character that you receive from the commport.....

    and don't forget to set comm properties and open the commport first before you can receive any data.
     
    Last edited: May 18, 2012
Loading...