dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Clear TextBox, on MSComm Receive

  1. #1
    Join Date
    Mar 2003
    Posts
    4

    Clear TextBox, on MSComm Receive

    Hi

    Im using the VB MSComm function to display incoming data strings to a TextBox. I have successfully set it up and it is working perfectly, but what i want to do is everytime a new string of data arrives i only want to display that, so i need to somehow clear the history of the textbox, for each Comm Receive.

    This is the method i tried to use, but unfortunately it only displays the new incoming data for a brief sec.
    Code:
    Private Sub MSComm1_OnComm()
        Dim InBuff As String
    
        Select Case MSComm1.CommEvent
    
            'When data is recieved do this
            Case comEvReceive
                Text1.Text = ""
                InBuff = MSComm1.Input
                Call HandleInput(InBuff)
    I know this is simple, sorry but does anyone have any other ideas how to clear textboxes, when a new string of data arrives.

  2. #2
    Join Date
    Apr 2000
    Location
    Southampton, UK
    Posts
    329
    As far as I can see, your code is fine for this part of it. However you need to understand the various interactions that take place. I would imagine that you have the .RThreshold property set quite low, for example = 1. This will mean that the OnComm event will fire when there are 1 or more characters in the receive buffer. This could easily cause a problem with what you are trying to achieve. If you know the length of your strings of data then you can set the property to the appropriate length and you will then see the content better. I am assuming that what is happening is that you get some or all of the content on one receive and then it is almost immediately cleared again when another event fires. Making .RThreshold higher will reduce this frequency (depending of course on the data that you are receiving).
    TimCottee
    I know a little about a lot of things and a lot about very little.

    Brainbench MVP For Visual Basic
    http://www.brainbench.com

    MCP, MCSD, MCDBA, CPIM

  3. #3
    Join Date
    Mar 2003
    Posts
    4
    Ahh Yes great thankyou Tim that was my problem, i had .RThreshold = 1 when really the data that i know coming in has over 40 characters.

    Thankyou

    Regards

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)