473,805 Members | 2,119 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reference form objects from a module

Hi

I have a module where I put all my functions and sub procedures. How do I
from the module best reference objects in other forms?

I have a form with a datagrid, and in the module I have a procedure to fill
this datagrid.
The datagrid is called dg, the form frmEventMain

Would this be correct:

frmEventMain.dg .Datasource = dt when I reference the datagrid in another
form?

/A.

Jan 17 '07 #1
3 1487
Lee
Andy:

It's not clear to me if frmEventMain is an instance of a form or the
name of the class wherein the form is defined. Assuming it's an
instance of the form you could...

1) Call your proc passing frmEventMain as a parameter
2) Call your proc passing frmEventMain.dg as a parameter
3) Assuming frmEventMain is visible within your proc, you could access
frmEventMain.dg directly.

My preference would be #2 because it would make your proc more
generally useful.

--
// Lee Silver
// Information Concepts Inc.

Andy.I wrote:
Hi

I have a module where I put all my functions and sub procedures. How do I
from the module best reference objects in other forms?

I have a form with a datagrid, and in the module I have a procedure to fill
this datagrid.
The datagrid is called dg, the form frmEventMain

Would this be correct:

frmEventMain.dg .Datasource = dt when I reference the datagrid in another
form?

/A.
Jan 17 '07 #2
Thanks

I'll give it a try
"Lee" <ls*****@inform ation-concepts.comwro te in message
news:11******** **************@ v45g2000cwv.goo glegroups.com.. .
Andy:

It's not clear to me if frmEventMain is an instance of a form or the
name of the class wherein the form is defined. Assuming it's an
instance of the form you could...

1) Call your proc passing frmEventMain as a parameter
2) Call your proc passing frmEventMain.dg as a parameter
3) Assuming frmEventMain is visible within your proc, you could access
frmEventMain.dg directly.

My preference would be #2 because it would make your proc more
generally useful.

--
// Lee Silver
// Information Concepts Inc.

Andy.I wrote:
>Hi

I have a module where I put all my functions and sub procedures. How do I
from the module best reference objects in other forms?

I have a form with a datagrid, and in the module I have a procedure to
fill
this datagrid.
The datagrid is called dg, the form frmEventMain

Would this be correct:

frmEventMain.d g.Datasource = dt when I reference the datagrid in another
form?

/A.
Jan 17 '07 #3
Andy.I wrote:
I have a module where I put all my functions and sub procedures. How do
I from the module best reference objects in other forms?
If a method requires a reference to a Form then pass it one as an
argument to the method.
Better still, if the method primarily affects the Form based on other
data that you supply, move the method into the Form class.
I have a form with a datagrid, and in the module I have a procedure to
fill this datagrid.
I would suggest that's the wrong way round.
I would attach this method to the Form and pass the data, however you
retrieve it, to the method.

HTH,
Phill W.
Jan 17 '07 #4

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

Similar topics

6
14039
by: Krackers | last post by:
How do you write a function which returns a reference to an array. I can only get a function to return a copy of the array itself. I've had a look at some other threads in this group an the return value of a function acts like 'by Val' returning the value only (except for objects) can you make it return a reference instead? cheers, Krackers
15
2142
by: Ron Adam | last post by:
Does anyone have suggestions on how to improve this further? Cheers, Ron_Adam def getobjs(object, dlist=, lvl=0, maxlevel=1): """ Retrieve a list of sub objects from an object. """
4
2619
by: Dave Lauberts | last post by:
Hi Sorry to ask a silly question, I am 'self taught' in using access vb and I came trying to use fIsAppRunning to see if excel is running in the background but when I try and compile the code I get a compile error 'Sub or Function not defined'. I assume I have to create a reference in 'Tools', 'References' but don't know which one. Can any body help me please?
7
2154
by: Weaver | last post by:
I need to create an object (a recordset) that will not go out of scope outside the sub that creates it. I've tried placing the Dim statement in the General area and in another mod as Global; neither works. (I'm creating the recordset with dynamic SQL.) Any ideas on this?
4
1665
by: Keith Chadwick | last post by:
I am having some trouble referencing an Application("myVar") variable from within a module.vb file on my ASP.NET site. According to the documentation I should be able to reference System.Web.HttpApplication but it does not seem to like that one bit. I also have a MSXML2.DOMDocument30 defined as a public object within the vb module which is loaded during the application start up with a bunch of XML. What is weird is that the data contained...
2
2678
by: Martin Ortiz | last post by:
Ugh.... All classes are copy by reference, even if you use "ByVal" and NOT "ByRef" it's still a copy by reference. Of course, as a consequence, if you change any values of the object you passed in, the original object is affected. I expect this with arrays, but not with single objects being passed "ByVal" to functions.... Is there a sane to get "ByVal" passing of parameters? (copying fields is not
2
7278
by: Mark D | last post by:
Hi Relative vb.net newbie here... I have a Windows Form application with a few subroutines in a separate module. From one of the subroutines, I want to get the value of a label or text box on the form. As it is, I get a "Reference to a non-shared member requires an object reference." error message. I can't seem to figure out how to tell the subroutine how to find and use the labels or text boxes on the form.
7
2848
by: =?Utf-8?B?Sm9lbCBNZXJr?= | last post by:
I have created a custom class with both value type members and reference type members. I then have another custom class which inherits from a generic list of my first class. This custom listneeds to support cloning: Public Class RefClass Public tcp As TcpClient Public name As String End Class Public Class RefClassList Inherits List(Of RefClass) Implements ICloneable
275
12436
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
9718
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10613
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10363
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10368
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10107
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9186
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.