473,379 Members | 1,201 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,379 software developers and data experts.

Referencing controls on an EXISTING instance of form

Please help with this one - I have scoured the newsgroups for information on
this, and all of the responses relate to how to refernce controls on a NEW
instanc of a form and not an exitsing one. I wish to access controls on an
EXISTING instance of my form from a module.

I have found one suggestion mentioned twice that works well - is this a
corect way of achieving this aim, or is there a neater alternative:-

The answer that I have found is to create a module with a Sub Main in it and
set this as the Startup Object:-

Module Startup
Public myMainForm As Form1
Sub Main()
myMainForm = New Form1
Windows.forms.Application.Run(myMainform)
End Sub
End Module

As I say - this works well, but is there a better way of doing this??

Many thanks
Paul Bromley
Nov 20 '05 #1
1 1087
"Paul Bromley" <fl*******@dsl.pipex.com> schrieb
Please help with this one - I have scoured the newsgroups for
information on this, and all of the responses relate to how to
refernce controls on a NEW instanc of a form and not an exitsing one.
I wish to access controls on an EXISTING instance of my form from a
module.

I have found one suggestion mentioned twice that works well - is this
a corect way of achieving this aim, or is there a neater
alternative:-

The answer that I have found is to create a module with a Sub Main in
it and set this as the Startup Object:-

Module Startup
Public myMainForm As Form1
Sub Main()
myMainForm = New Form1
Windows.forms.Application.Run(myMainform)
End Sub
End Module

As I say - this works well, but is there a better way of doing
this??


Yes. If you want to access an object, pass the reference to the object that
needs the reference. This is the case for all other types of objects, so I
don't see the difference to Forms.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2

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

Similar topics

6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
6
by: Nathan Sokalski | last post by:
I am trying to dynamically add controls to my page, but am having trouble with controls such as buttons. I have been able to add simple controls such as Label controls, because they can be placed...
7
by: jcrouse | last post by:
I want to add controls (labels) at runtime to a different form. Here is the code that is being is under a button on form2: Dim frm1 As New Form1 Dim MyLabel As New Label MyLabel.BackColor =...
2
by: Axel | last post by:
Hi, a question about something that seems very simple at first glance: is it possible to reference other controls of a subform in a query window without referencing through the parent form? I...
21
by: cmd | last post by:
I have code in the OnExit event of a control on a subform. The code works properly in this instance. If, however, I put the same code in the OnExit event of a control on a Tab Control of a main...
8
by: mark.norgate | last post by:
I've run into a few problems trying to use generics for user controls (classes derived from UserControl). I'm using the Web Application model rather than the Web Site model. The first problem...
1
by: Maart_newbie | last post by:
Hi all, I have a an instance of a form, lets say Form2, that is constructed from within a event handler of an instance of Form1, subsequently I call ShowDialog with the instance of Form1 as its...
2
by: ccsnavy | last post by:
For some reason referencing an unbound control on an active form from a query has ceased to work correctly. While other previously existing references to unbound controls in the same form seem to...
16
by: Mike | last post by:
Hi, I have a form with some controls, and a different class that needs to modify some control properties at run time. Hoy can I reference the from so I have access to its controls and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.