Link to home
Start Free TrialLog in
Avatar of born4code
born4code

asked on

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?
Avatar of rspahitz
rspahitz
Flag of United States of America image

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.
Avatar of inthedark
Are you talking about sharing your classes across several projetcs?
Avatar of born4code
born4code

ASKER

To clarify a bit more... let me give you an example...

.NET
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

VB6
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?




ASKER CERTIFIED SOLUTION
Avatar of inthedark
inthedark
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
inthedark...

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

So...

- 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..

Then...

- 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.
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?