Solved

# Plotting in MS Chart

Posted on 2003-03-13

I have been using VB 6 Black Book to design a UI and have gotten as far as outputting a textfile and generating numeric arrays from the text strings. The next step will be to plot or chart selected arrays vs. each other( i.e time vs. distance, velocity, acceleration). I am attempting to use MS Chart but will try Excel if all fails. Can you offer a reference and/or sample code to set X and Y to specific data arrays?

I can parse a text output file into various arrays:

Dim NewLine As String

Dim MyString As String

Dim NewString As String

Dim LeftString As String

Dim Time() As Variant, Travel() As Variant, Velocity() As Variant, Acceleration() As Variant, Breech() As Variant, Mean() As Variant, Base() As Variant, Temp() As Variant, Burn1() As Variant, Burn2() As Variant, Burn3() As Variant, Burn4() As Variant, Burn5() As Variant

ReDim Time(10000), Travel(10000), Velocity(10000), Acceleration(10000), Breech(10000), Mean(10000), Base(10000), Temp(10000), Burn1(10000), Burn2(10000), Burn3(10000), Burn4(10000), Burn5(10000)

Dim i As Integer

Dim A As Integer

Open "C:\Guns\Output.Out" For Input As #1

Do Until LeftString = "(PSI) (PSI) (PSI) (K)"

Input #1, MyString

LeftString = Left(MyString, 30)

Loop

NewString = Mid(MyString, 37)

i = 1

Select Case NewString

Case "1"

Do Until MyString = "PROJECTILE EXIT"

Input #1, MyString

If (Left(MyString, 1)) = "0" Or (Left(MyString, 1)) = "1" Or (Left(MyString, 1)) = "2" Or (Left(MyString, 1)) = "3" Or (Left(MyString, 1)) = "4" Or (Left(MyString, 1)) = "5" Or (Left(MyString, 1)) = "6" Or (Left(MyString, 1)) = "7" Or (Left(MyString, 1)) = "8" Or (Left(MyString, 1)) = "9" Then

Time(i) = (Val(Mid(MyString, 1, 7)))

Travel(i) = (Val(Mid(MyString, 8, 7)))

Velocity(i) = (Val(Mid(MyString, 15, 8)))

Acceleration(i) = (Val(Mid(MyString, 23, 9)))

Breech(i) = (Val(Mid(MyString, 32, 9)))

Mean(i) = (Val(Mid(MyString, 41, 9)))

Base(i) = (Val(Mid(MyString, 50, 9)))

Temp(i) = (Val(Mid(MyString, 59, 7)))

Burn1(i) = (Val(Mid(MyString, 66, 7)))

i = i + 1

End If

Loop

A = i Mod 10000

If A <> 0 Then

ReDim Preserve Time(A), Travel(A), Velocity(A), Acceleration(A), Breech(A), Mean(A), Base(A), Temp(A), Burn1(A), Burn2(A), Burn3(A), Burn4(A), Burn5(A)

End If

ETC. ETC. ETC.

Using Check boxes and Option buttons, I want to plot the Velocity, Accelration, Breech, and others against the time or travel array. I have tried several attempts with MSChart similar to:

Dim rowLabelCount, columnLabelCount, rowCount As Integer

Dim columnCount, labelIndex, Column, Row As Integer

GRAPH.chartType = VtChChartType2dXY

GRAPH.ChartData = Velocity

and a datagrid.

I am not familiar with the steps to go from array to chart and would very much appreciate some feedback.

Thanks,

RDXBrewer