Hi All,
I am a relative newcomer to programming in VB. I am developing an
application which has dozens of forms on which I need to plot graphs
in Picture boxes.
I have written a number of routines to help in plotting graphs as
follows:
1. Plots the axes of a graph given some parameters.
2. Plots a grid given parameters.
3. Plots splined curves given an array of points
etc … you get the picture.
These routines are up to 100 lines of code by the time they do
scaling, plot axis ticks, plot arrow heads, put captions and numbers
on the scales etc
The plan is to place these in a Module (*.bas) and call them as
required from each of the forms where I plot graphs.
Now the question:
When I call the plotting routines in the module from the code for a
particular form, is there a way to pass the names of the forms and
picture box to the plotting routine so that the generic code in the
plotting routine may plot directly onto the required form / picture
box. How do I use this information in the commands such as
Form.Picture#.Line ()-() etc within the module code.
Following is a simple example of plotting a line (which does not work
!) that shows what I am trying to do:
Form1 Code
Private Sub Form_Load()
Dim xstart As Single, xend As Single, ystart As Single, yend As
Single
Dim object_name As String
xstart = 0#
xend = 10#
ystart = -2#
yend = 2#
object_name = "Form1.Picture1"
Picture1.Scale (-1, 5)-(11, -5)
Call lineplot(xstart, xend, ystart, yend, object_name)
End Sub
Module1 Code
Sub lineplot(x1 As Single, x2 As Single, y1 As Single, y2 As Single,
object_name As String)
Object_name.Line (x1, y1)-(x2, y2)
End Sub
Any advice will be greatly appreciated !!
Thanks,
Stephen