VB.NET

Moderators: seancampbell
Number of threads: 4020
Number of posts: 10026

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
How to Declare Global Variables in a Module Posted by CitizenOlek on 14 Apr 2008 at 1:36 PM
Hello,

I need to access variables from multiple forms so
I asked someone the above and got this answer:

Put the array, and other global variables in a class with shared properties. That way each form can read and write to the array, but the two forms don't have to know about each other.

So! How do I Put the global variables in a class with shared properties?

Report
Re: How to Declare Global Variables in a Module Posted by jbassmanp on 15 Apr 2008 at 7:10 AM
: Hello,
:
: I need to access variables from multiple forms so
: I asked someone the above and got this answer:
:
: Put the array, and other global variables in a class with shared
: properties. That way each form can read and write to the array, but
: the two forms don't have to know about each other.
:
: So! How do I Put the global variables in a class with shared
: properties?
:
:
The way I've done this and it works perfectly for me. 1. Create module, 2. place the variables in the module like so:

Module Modudle1
Public Answer As DialogResult
Public Brofrm, Scanfrm As Boolean
Public x, GetErec, Records, xx, u, TabID, SHeight, SWidth As Integer
Public SecureLevel, logn, Reportname, DateName, theFile As String
Public SumObject, Mydate As Object

PS you can also place subs and function here that can be used from any form such as

Public Sub's and Public Functions.... You don't have to place them within each form but this way they are available to the entire project.... Good luck with your coding.


Report
Re: Global Variables [RESOLVED] Posted by CitizenOlek on 22 Apr 2008 at 2:54 PM
Thanks! It's so confusing sometimes.
I was told very explicitly that VB 2005 does not support Global variables.
But obviously your example works.
This post can be marked RESOLVED!

Thanks again.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.