Click to See Complete Forum and Search --> : PLOTTING X,Y VALUES??


HEIDI
January 7th, 2000, 07:55 AM
Can anyone tell me what would be the best control to use to plot x,y values on an axis. I have tried the graph control, but I can't get it to relate the x to the y and I can't seem to find a way with the mschart control either. Please help!!!

Dave Straayer
January 9th, 2000, 12:53 PM
Any picture or form control will work just fine. You just need to establish the coordinate system you want, as the default is in TWIPS and uses the "origin at upper left, Y increases downward" Windows standard rather than the Cartesian "Y+=up" direction. But you can change the direction using SCALE. One tip: if you try to do graphics in the Form Load, make sure that you make the form visible before you do the graphics.



Dave Straayer
Varatouch, Inc.

Dave Straayer
January 9th, 2000, 01:20 PM
Try this:
Option Explicit

Private Sub Form_Load()
Dim x As Single
Dim y As Single
Form1.Visible = True
Scale (-20, 20)-(20, -20)
Line (-20, 0)-(20, 0)
Line (0, -20)-(0, 20)
x = -20
y = f(x)
Line (x, y)-(x, y)
For x = -20 To 20 Step 0.1
y = f(x)
Line -(x, y), vbRed
Next x
End Sub
Function f(x As Single) As Single
f = 0.05 * x ^ 2 - 2 * x - 4
End Function


Dave Straayer
Varatouch, Inc.

HEIDI
January 10th, 2000, 06:51 AM
Mr. Straayer,
I just received your reply to my question. I will definitely try your solution to see if it will work. Thank you for taking the time to reply.

What will be the easiest way to draw an x and y axis with labels?

Thanks
Heidi Hauser

Dr_Michael
January 10th, 2000, 07:09 AM
I have no answer to your question but I have a suggestion: I've used MSChart control in past and it had a bug with logarithmic charts. This bug was corrected with ServicePack3. So, maybe there are more bugs in this control except this I met. So, I suggest you to install Service Pack 3 before continue with your project. Good luck!

Michael Vlastos
Automation Engineer
Company SouthGate Hellas SA
Development Department
Athens, Greece