Looping, but with Live Data

  • Thread starter Thread starter SLL
  • Start date Start date
S

SLL

Hi All-

I'm looking for some ideas on how to simultaneously/continuously
perform calculations in VBA while receiving live data feeds.

I want to run a simple program that has a start and stop button.
Basically, I have a live data feed and want to do calcuations and
perform other functions only after I have pressed the "Start" button
and until I press the "Stop" Button. Pretty simple.

My problem is that I dont know entirely how to set this up.
Currently, I have all of my calcuations and functionality working
correctly, BUT my program is set up to call a Do Until loop when the
"Start" button is pressed, and therefore, I am not receiving my live
data feeds until I hit "Stop" and it breaks the loop.

My code is basic and as follows:

Worksheet:

Private Sub ResetButton_Click()
Worksheets("Front").Range("B3") = ""
End Sub

Private Sub StopButton_Click()
Worksheets("Front").Range("B3") = ""
Call MyCalcs(TRUE)

End Sub

Private Sub StartButton_Click()

Call MyCalcs(FALSE)

End Sub



Module1

Sub MyCalcs(StopProg As Boolean)

Do Until StopProg = True

'Instructions, calcuations, etc

DoEvents

'Instructions, calcuations, etc

Loop

End Sub


Can anyone point me in the right direction?

Thanks.

SLL
 
Hi, in my opinion, since DoEvents does not work as expected, you can try the
following.
Solution 1:
1. Store your live data into a temporary file
2. In your loop read data from the file and at the end of the loop wait for
sometime
Solution 2:
1. Call a function that will get the data from the live data and process
appropriately during each iteration of the loop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top