Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
This Document is not yet Rated  Rate this Document

Plotting Current Time on X-Axis Using the Visual Basic Now() Function

Primary Software: Measurement Studio>>.NET Support
Primary Software Version: 7.0
Primary Software Fixed Version: N/A
Secondary Software: N/A

Problem: I need to plot measurement data on the Y-axis vs. the measurement time on the X-axis of a ScatterGraph and would like to use Now() to get the time in VB.net. What is the proper procedure for doing so?

Solution:
The Double to DateTime conversion factor that the Measurement Studio graphs use states that a double value of 0.0 is equivalent to DateTime.MinValue and a double interval of 1.0 is equivalent to 1 second. The NationalInstruments.DataConverter class will convert to and from double and DateTime and TimeSpan with this conversion factor. For example, you could do the following:

Dim nowValue As Date = Now()
Dim convertedValue As Double = CDbl(DataConverter.Convert(nowValue, GetType(Double)))

ScatterGraph1.PlotXYAppend(convertedValue, MeasData)

Where MeasData is the data you want to plot.

You will also want to make sure that your graph is set up to show the major divisions as a DataTime. You can do this programmatically with the following code:
ScatterGraph1.XAxes(0).MajorDivisions.LabelFormat() = New NationalInstruments.UI.FormatString(FormatStringMode.DateTime, "h:mm:ss tt")

Related Links: Measurement Studio Support

Attachments:





Report Date: 12/12/2005
Last Updated: 12/13/2005
Document ID: 3SBHHJ9F

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit