Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieve data from txt file to generate CWGraph plot

Please help...I'm not sure this is even possible, but here is what I need to do.  I wrote a DAQ program that utilizes the CWGraph control.  Each second a data point is collected by the program and displayed in one of the CWGraphs.  The only problem I have is that if the program is closed or crashes for some reason, I lose the data plot in my CWGraphs.  The data points are collected in a txt file which is then later worked up in Excel.  My question is, is there a way to retrieve these data points from the txt file and re-generate the plots when the program is opened back up?  The program would then take back over and plot along in realtime.  I hope this is clear enough to understand.  Feel free to ask any questions and any input would be greatly appreciated!
0 Kudos
Message 1 of 4
(7,858 Views)
Hi Chris,

You should be able to read from a text file and load the data into a CWGraph.  You will have to parse the data from the text file so that it can be stored in a data structure, such as an array of doubles, that can be passed to the Plot function of the CWGraph.  You will have to cast the values that you parse from the text file as type double in order to store them in the array.

You could do this before starting your DAQ task that will read in and display new data.
Jessica
National Instruments
Product Support Engineer
0 Kudos
Message 2 of 4
(7,814 Views)
Thanks for the reply Jessica.  Can you point me to a thread or possibly show me an example of what you are referring to?  Thanks again!
0 Kudos
Message 3 of 4
(7,796 Views)
Hi Chris,

There is not a shipping example that would demonstrate exactly what you are looking for in your application.

The reading and writing to a file will require general VB 6.0 programming as Measurement Studio does not provide a feature to assist you with that.  If you are not familiar with File I/O in VB 6.0, this site may be a good starting point: File I/O - VisualBasic Examples .

Once again, parsing the input from the text file will also require general VB 6.0 programming.  I am not sure how your text file will be delimited, but you can use this example as a guide to parsing the input from the file: Parse String Using A Specific Delimiter .

To convert from strings to numbers in VB 6.0, you can use the Val() function.  More information about how to use that function can be found on MSDN: Val Function .

Once you have an array of doubles, you can plot the data on your waveform graph as usual.  If you are not familiar with how to plot an array to a CWGraph, please take a look at our shipping examples.  The Simple Graph example is a great starting point.
Jessica
National Instruments
Product Support Engineer
0 Kudos
Message 4 of 4
(7,790 Views)