Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Global variables

Posted on 1999-07-15
Medium Priority
Last Modified: 2010-05-02
I am fairly new to VB and I am working on aan application that has a number of forms and controls. I need to store the Combo Box selection of one form in a global variable and be able to check that value in another form. I tried declaring a public variable in the form where I was setting its value and checked the value of that variable in the other form. It didn't work.

Thanks for any help.
Question by:kavint
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 18

Accepted Solution

deighton earned 200 total points
ID: 1524969
if a public is declared in form1 then you get it in another form as


Author Comment

ID: 1524970
Thanks for your suggestion.

Expert Comment

ID: 1524971
I know its too late but , since i have seen now, just for the record avoid using Global variables if possible.
1)create a public function and and pass var to its arguments
2) if u want to use global variables u can even declare var in .bas file apart from the suggestion given by Deighton.

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question