Results 1 to 3 of 3

Thread: Live data from Comm1 via VB to Excel

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2007
    Posts
    2

    Live data from Comm1 via VB to Excel

    Hello

    First of all I’m a beginner in visual basic. I have to find a solution for my problem and I’m hoping some of you will help me.

    I try to read data from external device.


    ‘Private Sub Command_Click()

    ‘’time = Now()
    Debug.Print time + delay
    Do While Now() < time + delay
    Do
    DoEvents
    buffer = buffer & MSComm1.Input
    Loop Until InStr(buffer, vbCrLf)
    Text2.Text = buffer
    plot = CDbl(buffer)
    buffer = ""
    Loop
    “””


    ‘’


    ####Code Excel####

    oSheet.cells(i, 2) = plot

    ####code######

    End


    The Problem is I just get a last value when the time is over. What I want is to refresh (plot Variable) in Excel with every input change.


    Thanks in advance

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: Live data from Comm1 via VB to Excel

    Don't use a timer to time serial input. Use the OnComm event to check the buffer for vbCrLf. When you have it, the buffer will be filled with your data.

    CDbl(buffer) will only work if buffer (which has to be defined as String) contains a string that equates to a number. Check it and remove any non-numeric characters before converting it. If there's a vbCrLf in the middle of the string in the buffer, CDbl will throw an error.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2007
    Posts
    2

    Re: Live data from Comm1 via VB to Excel

    Thanks I got it

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