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

Global Objects?

What happened to global objects?

I want to make the main form accessible throughout all the classes as a
single instance, right now I have to make a cludgy pass back through the
class structure to get to a textbox.
Also, how do I setup an event listener on the global form that I can call
from a RaiseEvent in one of the classes?
thanks -J
Nov 20 '05 #1
4 1866
Hi Shadowboxer,

Globals have disappeared. Everything needs to be in a class. :-(

Globals have reappeared. You can have a Module which implicitly creates
the class for you. :-)

Regards,
Fergus
Nov 20 '05 #2
Hi there, I recommend you create a Sub Main in a module:

Public Module EntryPoint

Public fMainForm As MainForm

Public Sub Main(Arguments() As String)

fMainForm = New MainForm
Application.Run(fMainForm)

End Sub

End Module

Now, whereever you are, you can access fMainForm to be the main form.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Maybe it's a game called 'Punish the User'"
"Shadowboxer" <sh*********@mac.com> wrote in message
news:bj********@library2.airnews.net...
What happened to global objects?

I want to make the main form accessible throughout all the classes as a
single instance, right now I have to make a cludgy pass back through the
class structure to get to a textbox.
Also, how do I setup an event listener on the global form that I can call
from a RaiseEvent in one of the classes?
thanks -J

Nov 20 '05 #3
what keyword do I give the class in the module?

"Fergus Cooney" <fi******@tesco.net> wrote in message
news:Or**************@TK2MSFTNGP11.phx.gbl...
Hi Shadowboxer,

Globals have disappeared. Everything needs to be in a class. :-(

Globals have reappeared. You can have a Module which implicitly creates the class for you. :-)

Regards,
Fergus

Nov 20 '05 #4
Hi again Shadowboxer,

The beauty of a Module is that it needs so little work. You don't have to
worry about it being a class - it's all hidden.

Click on Add New Item...
Click on Module
Give it a name, eg Globals.vb, or modGlobals.vb, or whatever.

You'll see a pretty empty code window

- Module Module1
|
|_End Module

Change its name, eg Globals, or leave it as it is (but consistency
with the filename is useful).

Type your globals.
Const sProgrammer As String = "Shadowboxer"
Public iGlobalCounter As Integer = 1

These will be available everywhere without qualification.

Take a look at the example that Tom gave - it shows you how to deal with
your Main Form question.

Regards,
Fergus
Nov 20 '05 #5

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

Similar topics

2
by: Gianguz | last post by:
I'd like to discuss about the opportunity to have a global objects creator that introduces into a general framework (suited for multithreading) a controlled semantic to manage globals variables...
2
by: Thomas Matthews | last post by:
Hi, I'm getting linking errors when I declare a variable in the global scope, but not inside a function. The declarations are the same (only the names have been changed...). class Book {...
8
by: john townsley | last post by:
whats the best way to declare Global objects (holding say 10 member variables and functions) of an unknown size in c++, memory efficient as possible thanks
59
by: seberino | last post by:
I've heard 2 people complain that word 'global' is confusing. Perhaps 'modulescope' or 'module' would be better? Am I the first peope to have thought of this and suggested it? Is this a...
10
by: David P. Donahue | last post by:
When I wrote websites in VB .NET, I would often put functions in Global for all the pages to call. Now, in C#, doing so results in "references to non-static objects" and whatnot. I realize what...
15
by: randyr | last post by:
I am developing an asp.net app based on a previous asp application. in the asp applications global.asa file I had several <object id="id" runat="server" scope="scope" class="comclass"> tags for...
8
by: Vishwanathan Raman | last post by:
Hi I have a declared a static DataSet object SOBJ in Global.asax.I also have a localy defined DataSet LSOBJ in Global.asax which I am storing in Application State.Is there any technical...
23
by: David Colliver | last post by:
Hi, using c#, 1.1 I know that we are not supposed to use global variables etc. in c# I am having a problem, but not sure how to resolve. I did have another post here, but may have over...
24
by: onnodb | last post by:
Hi all, Currently, I'm working on an Access XP database app that uses two global objects in its code. These two objects are instances of "controller classes". For example, one of them manages...
112
by: istillshine | last post by:
When I control if I print messages, I usually use a global variable "int silent". When I set "-silent" flag in my command line parameters, I set silent = 1 in my main.c. I have many functions...
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: 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...
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
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
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
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...

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.