Solved

Global Variables

Posted on 2003-11-04
4
516 Views
Last Modified: 2010-05-03
What is the command in VB6 to set a variable in a module?

I want to say:
Variable1 = 25
but I don't remember how to say that...
0
Comment
Question by:JFrye
  • 2
4 Comments
 

Expert Comment

by:pyromatt
ID: 9679377
If the variable is global you should be able to say just that. To declare it globally you just use the following;

Global Variable1 as Integer
0
 

Author Comment

by:JFrye
ID: 9679459
I have that much, but I need to set the value of Variable1 to 25 in this example. How do I set the value?
0
 
LVL 4

Accepted Solution

by:
TomLaw1999 earned 20 total points
ID: 9679537
If the value is constant available to all forms then

Public Const Variable1 As Long = 25

_____________________________

if it is a true Public variable then
Public Variable1 As Long

Then enter the value 25 in an appropriate place i.e.

sub Main()
Variable1 = 25
end sub






0
 

Author Comment

by:JFrye
ID: 9680193
Oh yeah! The SubMain() was what I was looking for. Thanks!
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

726 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