Qbasicnews.com

Full Version: [Resolved] Visual Basic 6 Type/End Type Frustration
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm working on a game in VB6. In a seperate module, I've declared a bunch of Public Types, then declared some variables to represent them. What I want to do is have those variables transfer over to other forms.

However, when I do try to represent the declaration (i.e., foo.bar or whatever) in another Form, VB6 complains that that declaration doesn't exist. I thought that when you declare/DIM something in a module it's automatically made public.

I've declared the type structs (if that's what you call them) before any Subs within the module.

Hope I've explained it correctly.
Its been a long time but i think you have to declare them GLOBAL in a module, ie:

Code:
Global foo As bar
That worked. Thanks.
It's better to define the stuff as public, and then use the correct naming convention to access it. For example, say you have this module called MOMO.BAS:

Code:
Public value As Integer

Public Sub mysub (ByVal i As Integer)
   Print i
End Sub

You use momo.value to read/write to the variable, or momo.mysub to call the sub,

Avoid globals, most of the time they are *not* needed.