473,396 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Passing Form and Object Names

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
Jul 17 '05 #1
1 3163
On 27 Jul 2003 19:55:50 -0700, sm*********@yahoo.com (smjmitchell)
wrote:

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.


You can pass an Object to the routine in the .BAS module

This could be a Form or a Picturebox

Public Sub Plot1( O As Object, Var1, Var2

Public Sub Plot1( F As Form, Var1, Var2

Public Sub Plot1( Pic As PictureBox, Var1, Var2

All of the above are valid methods
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
7
by: Steven T. Hatton | last post by:
I am trying to convert some basic OpenGL code to an OO form. This is the C version of the program: http://www.opengl.org/resources/code/basics/redbook/double.c You can see what my current...
6
by: Mark Anderson | last post by:
I have code to develop result page links (like a search engine) for some results being passed from a database where I've no server-sdide acces - thus JS. The code is below and works fine except...
20
by: Gregory Piñero | last post by:
Hey guys, would someone mind giving me a quick rundown of how references work in Python when passing arguments into functions? The code below should highlight my specific confusion: <code> ...
0
by: Neelima Godugu | last post by:
Hi All, I have developed a windows forms user control, which I am going to host in Internet Explorer.. I am familiar with the security settings requirement inorder to do the above. I have...
5
by: DC Gringo | last post by:
I've got a command button to submit a value from a dropdown list that should then filter a SELECT query. I'm simply appending a WHERE colx = <variableSelectedFromDropdownList>. How do I pass this...
3
by: Troy | last post by:
I'm trying to pass a form to a class method then have the class instantiate and instance of the form and open it. Is there a way of creating a form from its class name (a string variable) or from...
1
by: | last post by:
Hi, 1st, I did a search and could not find any info on this, the Google results were good, but I'm still have issues...So any help will be great. I have a frame page, which contains 3 frames...
1
by: rfr | last post by:
I have a need to use a single version of a Visitor Response Feedback Form on numerous HTML documents. Rather than have numerous versions of this, one on each HTML document, it makes more sense to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.