RDXBrewer
asked on
Plotting in MS Chart
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Graphs are graphical representation of arrays. Either you use arrays, or spreadsheets (they actually store arrays).
Why cant you make arrays public in a form? Simply declare the arrays in the declaration section and they are public.
Why cant you make arrays public in a form? Simply declare the arrays in the declaration section and they are public.
ASKER
My problem was much more complex than the Chart Sample, But it did send me in the right direction.
I appreciate the reference.
I have 500 more points for 2 more references:
1)Printing Options and Printing without Printform: I have to print the graphs I have created along with a textbox summarizing the peaks. I have created a form that is the preview I want to print. Next I:
dim obj as printer
'change options
obj.orientation=2
obj.print quality=-3
obj. ETC, ETC, ETC
Set obj as printer
printform
Obviously, this is wrong...I need a simple working source code.
2)I need to export an array(size,6) into 6 columns in Excel. I have not even begun to think about how to do this. I would like to get a reference or two.
Let me know if you are interested in the points and I will post the question.
Thanks Again Sethi,
RDXBrewer
I appreciate the reference.
I have 500 more points for 2 more references:
1)Printing Options and Printing without Printform: I have to print the graphs I have created along with a textbox summarizing the peaks. I have created a form that is the preview I want to print. Next I:
dim obj as printer
'change options
obj.orientation=2
obj.print quality=-3
obj. ETC, ETC, ETC
Set obj as printer
printform
Obviously, this is wrong...I need a simple working source code.
2)I need to export an array(size,6) into 6 columns in Excel. I have not even begun to think about how to do this. I would like to get a reference or two.
Let me know if you are interested in the points and I will post the question.
Thanks Again Sethi,
RDXBrewer
I can solve the first question as I myself am using a printing code to print MScharts with my applications.
ASKER
Check out "Points for Sethi" Question.
ASKER
http://www.freevbcode.com/ShowCode.Asp?ID=1538
was not what I was looking for....But the MSDS example seems close. Some questions:
Do I have to input my arrays into a spreadsheet in order to plot them?
I can't seem to make arrays public in a form, do I need a module, and what is the difference between the two?
thanks for the feedback,
RDXBrewer