|
-
Sep 26th, 2016, 01:26 PM
#1
Thread Starter
Hyperactive Member
Problem with public variable - Not possible to get its value
I have created a module where I declare a Public variable.
Code:
Public Const MyVariable = 5
In another form I try to get its value and show it in a MsgBox
I get an empty Msgbox. I don't know why it happens and how I can solve it.
I thought that I would get a Msgbox containing the value 5.
-
Sep 26th, 2016, 03:23 PM
#2
Re: Problem with public variable - Not possible to get its value
You would unless you have another variable defined with the same name or you have a miss spelling on one of those.
-
Sep 26th, 2016, 04:30 PM
#3
Re: Problem with public variable - Not possible to get its value
I have created a module where I declare a Public variable.
if it is an object module, you will have to prepend the module name
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Sep 26th, 2016, 10:26 PM
#4
Re: Problem with public variable - Not possible to get its value
Also note that you should be using Option Explicit in your code to require variable definitions so that you get a compile error when a variable is accessed outside its scope.
-
Oct 1st, 2016, 08:12 PM
#5
Re: Problem with public variable - Not possible to get its value
Hey Data...long time, no hear (my fault, been busy doing other things). Don't know why people don't learn that basic, and I mean, BASIC, "trick" of using OE. Yeah, it took me some time to learn it, as well, but when I did.....NEVER WENT BACK.
Jose, post your project (probably doesn't contain private info)....folks here can IMMEDIATELY identify your REAL issue.
Sammi
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|