2 Replies - 2967 Views - Last Post: 02 April 2008 - 02:35 AM Rate Topic: -----

#1 davkav   User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 35
  • Joined: 11-March 08

Declare variables to work in numerous forms

Posted 01 April 2008 - 07:36 AM

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??

Is This A Good Question/Topic? 0
  • +

Replies To: Declare variables to work in numerous forms

#2 Martyr2   User is offline

  • Programming Theoretician
  • member icon

Reputation: 5227
  • View blog
  • Posts: 14,010
  • Joined: 18-April 07

Re: Declare variables to work in numerous forms

Posted 01 April 2008 - 11:24 AM

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! :)
Was This Post Helpful? 1
  • +
  • -

#3 davkav   User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 35
  • Joined: 11-March 08

Re: Declare variables to work in numerous forms

Posted 02 April 2008 - 02:35 AM

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 ;)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1