Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Plotting in MS Chart

Posted on 2003-03-13
6
Medium Priority
?
400 Views
Last Modified: 2008-03-10
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
0
Comment
Question by:RDXBrewer
  • 3
  • 3
6 Comments
 
LVL 18

Accepted Solution

by:
Sethi earned 1500 total points
ID: 8132724
Look at this code:
http://www.freevbcode.com/ShowCode.Asp?ID=1538

There is another example In Samples folder where you have installed your VB.
0
 

Author Comment

by:RDXBrewer
ID: 8138959
Unfortunately,
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
0
 
LVL 18

Expert Comment

by:Sethi
ID: 8140476
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.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:RDXBrewer
ID: 8187276
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
0
 
LVL 18

Expert Comment

by:Sethi
ID: 8188601
I can solve the first question as I myself am using a printing code to print MScharts with my applications.
0
 

Author Comment

by:RDXBrewer
ID: 8192229
Check out "Points for Sethi" Question.

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month14 days, 20 hours left to enroll

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question