06-09-2005, 07:13 AM
Anyone know how to make a line chart that updates the data every 10 ms and the chart just show latest 10 sec datas.
so it's like Stock chart with ticks time scale
like this ---> http://www.dailyfx.com/fxpowerchart/ChartStation.html
chart type = Line chart
Time scale = Ticks
but in VB.
If anyone have the sample program... please attach.
06-09-2005, 02:24 PM
You can use the timer control to send the WM_TIMER messages every x miliseconds. Just place the timer control on your form and double click it and an event handler for these messages will be created. You then write the code you need there.
However, please note that the timer is not much accurate. Second, its basic interval is (or at least was - try it) 1/18.5 sec. Third, if there are two or more WM_TIMER messages in your message qeue, then Windows leaves you just one and deletes all the other. So even if ten messages arrived and you forgot to process them, you will see only one message. Therefore, reading the system time inside the timer handler is a better way then summing the number of times the handler was called.
Also, there's the GetTickCount API function. Take a look at it.
As for displaying the last ten seconds of data, the easiest way to do it is to make a circular array. This means that you make an array just the size you need and loop the starting point through it. It can be done in a pretty straightforward way
' Make an array of 100 elements
dim a(0 to 99) as long
dim start as long
' Get n-th element
' use mod the array size
x = a((n+start) mod 100)
' Add a new element
a( (n+start) mod 100) = new_element
start = (start + 1) mod 100
' Remove the last element
start = start - 1