• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 231
  • Last Modified:

Need help organizing Class files

I think .net has really spoiled me.
I'm trying to figure out a way to somewhat "organize" my class files.

Where in .net I can give each class file a name, the class code a name, and even add a namespace... is there anything that I can do remotely like this in VB6?

It feels like I am defeating the purpose of organizing the code if I am just dumping vb6 form-behind code into class modules.... if no organization possiblities exist...

Any help?
  • 3
  • 2
  • 2
1 Solution
I'm not really sure what you're asking.
In .Net, the Namespaces definitely help.

In VB6, I usually just name all of my classes with a cls prefix so they sort together in the project.

And all of your forms are really essentially classes so there's usually no need to move the code into a separate class.

And if you don't need the features of a class, but just a common placeholder for code, make yourself a module.
Are you talking about sharing your classes across several projetcs?
born4codeAuthor Commented:
To clarify a bit more... let me give you an example...

A class file name of Whatever.vb,
A Class Name inside of the Whatever.vb file, let's  Public Class MyWhatever
And, I can wrap the class with a namespace, like MyWhateverNamespace

Your advice of just naming the files with the same alphabetical character

Golly, isn't there something a little better than I can do in VB6 rather than just rename a file to a better name?  "I understand you logic that a form is a class anyway"... but I am trying to organize my code in class files and get as close to a .NET model as I possibly can.

Sharing --- Not really.  Actually, however I have used a DLL like this in the past, inside of a project.  Is that what you are referring to?  Perhaps that is another way to tackle this?

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Yes was going to suggest that next, but the downside of DLLs is that if you are just using compiled DLLs it become a pain, but can be improved.......You can get a little closer to .net by coding with multiple projects simultaneously.

So you create your Main project. You can also create another project, say with a project name like MyWhaterverNameSpace. When you want to test the entire application, you open your main project, select File-Add Project ans select the MyWhaterverNameSpace project. You can then click on the Main project and set a reference to the MyWhaterverNameSpace project.

So in your Main project you can then define Public objects/variables within a standard module like this:

Global MyWhaterverNameSpace.MyClass As MyClass

Or make private declarations within other functions/classes

Dim MyWhaterverNameSpace.MyClass As MyClass
So anywhere within main project you can now use the properties/methods of MyClass.  The joy is that you can now change the code simultaneously in both projects.

I use this strategy with several types of libraries, for example if have a GF (gereral functions with project name zGF) project, so at the top of forms, just type  Dim GF As New zGF. Or in a module Global GF As New zGF.

So its kinda like Imports....
In all fairness, you're looking at older technology.  I think that VB6 showed up around the time of Windows 98.  It was good at the time, but we've obviously found better ways to do things.

I personally like the DotNet #Region command for organizing code.  I wouldn't expect VB6 to have something that lets me easily organize code like that because it was a relatively new idea.

Granted, namespaces are not new, but they were always very well hidden in previous versions of VB.

I would suggest doing what you're doing (which is pretty good) and see if it's possible to start migrating this project to DotNet so you can take advantage of all the new features you like.
born4codeAuthor Commented:

sounds interesting.  i can vaguely remember doing something like this a long time ago...


- I assume that the extra project I create is an "ActiveX dll project", and I must compile it
- After compiling, it is available in the reference menu, which I point to that project etc..


- After adding the new project reference, I make some changes to it (right there).
- Now I need to compile my exe... don't I have to go BACK to the referred dll project and recompile the dll?

Obviously, I would have to include the referenced dll in my setup package, yes?

Thanks again.
born4codeAuthor Commented:
Oh yeah almost forgot..

Do I have to remove the extra project when I get ready to deploy?  Or do I need BOTH the added project AND the reference?

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now