?
Solved

Global Variables

Posted on 2003-11-04
4
Medium Priority
?
518 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
[X]
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
  • 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 80 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month13 days, 3 hours left to enroll

777 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