CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Posts
    41

    calling a serialport handle from a loop

    Hi guys his my problem:
    I am trying to run the function:
    Code:
     Private Sub port_dataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles port.DataReceived
    from inside a while loop of a different function ie.
    Code:
     While A_switch = 0
    
                System.Threading.Thread.Sleep(100) ' Sleep for .1 second
                calabrate_send = calabrate_send - 5
                port.WriteLine("9 1 ")
                port.WriteLine(calabrate_send)
                port.WriteLine("a")
    end While
    the real problem is that the serial call updates the value of A_switch which is need to exit the loop at the correct time
    if anyone knows how to do this or has a better method i would love to hear -cheers robbo

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: calling a serialport handle from a loop

    Show more code.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Mar 2004
    Posts
    41

    Re: calling a serialport handle from a loop

    solved the problem using
    Code:
    System.Windows.Forms.Application.DoEvents()
    however this results in a heep of data at the serialport buffer built up hence i might need to use clear to send i guess
    thanks

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured