Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 132,298 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,014 people online right now. Registration is fast and FREE... Join Now!




Declare variables to work in numerous forms

 
Closed TopicStart new topic

Declare variables to work in numerous forms

davkav
post 1 Apr, 2008 - 06:36 AM
Post #1


New D.I.C Head

*
Joined: 11 Mar, 2008
Posts: 35



Thanked 1 times
My Contributions


OK simple question can i declare variables in one place so that they can be used in multiple forms.

In other words so i dont have to declare them on every form.

Say for eample I have a text box and its retrieving its value from an outside interface. the variable is continuously changing.

I have 3 forms, and on each one i have to declare the same variables for my code and setup the connection to my interface.

Can I not set the code up in such a way that when it loads all forms work from it??
User is offlineProfile CardPM

Go to the top of the page

Martyr2
post 1 Apr, 2008 - 10:24 AM
Post #2


Programming Theoretician

Group Icon
Joined: 18 Apr, 2007
Posts: 5,026



Thanked 173 times

Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions


Yes, you can put this code into a module. If you go to your project on t he right and add items, you should see the option to add a module (this will be a bas module). Modules are tied to the project itself and can have a global scope that allows all forms to see variables, functions etc defined there.

Here is a little taste of what they can do...

Modules (.BAS files)

Feel free to research the idea of a BAS module some more and remember to use global variables sparingly. They often lead to bad design (and design problems later) if used too much.

Enjoy! smile.gif
User is online!Profile CardPM

Go to the top of the page

davkav
post 2 Apr, 2008 - 01:35 AM
Post #3


New D.I.C Head

*
Joined: 11 Mar, 2008
Posts: 35



Thanked 1 times
My Contributions


excellent, thanks for the reply man!

I had added a module and messed around with that alright, couldnt get it working and wasnt 100% if that was the right way so i gave up.

Now I know its the correct way ill give it another shot.

Thanks Again wink2.gif
User is offlineProfile CardPM

Go to the top of the page

Closed TopicStart new topic
Time is now: 11/22/08 01:35AM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month