|
-
Dec 19th, 2005, 11:59 PM
#1
Thread Starter
Lively Member
newbee...ploting a graph
hey guys i'm not good at all at vb have only been doing it a month and not for much of that month, thing is i've to submit a maths project to include a vb app as part of it.
basically i have a programm that will write the solution to an equation over a interval to at txt file. that i can do. it looks stg like this in the txt file
(the vb app uses a loop to generate the y vaulues for each x)
x1 y1
x2 y2
x3 y3
x4 y4
etc
what i then do is open an excel doc and plot the x's vs y's to get a nice graph!!!
what i want to do is to have the vb app create its own graph and plot the points itself.. i've a feeling this is possible because i saw in the "ole" box you can choose to create a graph. but thats as much as i know.
any help or guidance would be much apprecieated!!!
thanks....james
-
Dec 20th, 2005, 12:03 AM
#2
Frenzied Member
Re: newbee...ploting a graph
so u want to create a graph in excel using the data in your text file?
PS welcome to the forums...
let me try some code myself first....
-
Dec 20th, 2005, 12:05 AM
#3
Re: newbee...ploting a graph
Welcome to the forums
This is to add the chart to your own program, not excel.
To put a graph similar to Excels (actually exactly like excel's) you'll need the microsoft chart control. To load it goto components (in the project menu) and scroll down to it and select it. You then use columncount and rowcount to set how many columns and rows you need, then move through them useing column and row properties and add your values in the data property.
-
Dec 20th, 2005, 12:24 AM
#4
Thread Starter
Lively Member
Re: newbee...ploting a graph
thanks guy
i got that ms chart thing up but i'm not sure if its what i'm looking for
i need an x y scatter chart
all my programme is is basically a loop
it loops x values from say -3 to +3
then it returns a y vaule for a particular x
then it loops back and but in a new value for x
then out comes a new value for y
as it goes through each loop it writes the x and y values to a txt file
which i can then import to excel and plot the graph
what i need is not to use excel at all..
please.. speak to me like i;m retarded!!!
-
Dec 20th, 2005, 12:28 AM
#5
Thread Starter
Lively Member
Re: newbee...ploting a graph
ohh
just found an x y scatter chart
how to i tell it my x and y values???? i think thats my problem
-
Dec 20th, 2005, 12:32 AM
#6
Re: newbee...ploting a graph
-
Dec 20th, 2005, 07:41 AM
#7
Re: newbee...ploting a graph
The easiest way to plat data is to put it into a 2-d array where
arrData(i,1) = Xi
arrData(i,2) = Yi then use the ChartData Property of the MSChart control.
VB Code:
MSChart1.ChartData = arrPrices
For your purposes set the Chart type to VtChChartType2dXY
Here is an example
VB Code:
Dim arrPrices()
Dim i As Integer
Dim maxval As Integer
MSChart1.chartType = VtChChartType2dXY
maxval = 100
ReDim arrPrices(1 To maxval, 1 To 2)
For i = 1 To maxval
'X-value
arrPrices(i, 1) = Sin(i / 5) * 50
'y-Value
arrPrices(i, 2) = Sin(i / 10) * 50
Next i
MSChart1.ChartData = arrPrices
If you set ChartType to VtChChartType2dLine, then you don't need X-values. A 1-d array in this case will plot Y-values vs. x=1,2,3,4,... A 2-d Array will plot two data sets.
-
Dec 20th, 2005, 11:52 AM
#8
Thread Starter
Lively Member
Re: newbee...ploting a graph
hey moeur
thanks a mil
havnt got it to work for my particular app yet but at least i can get the graph to plot from your code so i have a solid starting point all i need to do now is adapt, i never knew about "arrays" before (as my name suggests i am a fish!) but i figure once i brush up on them i should get some kind of result.
if i succeed i'll post again (give me a few days!!!!)
james
-
Dec 20th, 2005, 01:29 PM
#9
Thread Starter
Lively Member
Re: newbee...ploting a graph
woo hoo woo hoo
i got it to work
thanks a million you guys!!!
now i can concentrate on thermodynamics (exams post christmas)
just one thing if anyone could help me
when i start the app the graph is there but theres already 4 crazy plots on it
when i run the app they dissappear and my plot comes up
how can i get the graph to be blank as soon as i open the project???
dont worry if you dont know, its functional now anyways!!!
thanks again
james
-
Dec 20th, 2005, 08:48 PM
#10
Fanatic Member
Re: newbee...ploting a graph
how can i get the graph to be blank as soon as i open the project???
dont worry if you dont know, its functional now anyways!!!
try setting the chart value = nothing or "" on formload....
-
Dec 20th, 2005, 09:04 PM
#11
Re: newbee...ploting a graph
Go to properties of the graph, and delete the values that draw the default chart.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|