Hello, Id like to start by saying that I am a beginning programmer. Ive almost finished my code optimizer as my first serious project. What Ive designed this program to do it go through a source (.vbp) file and clean up the coding (removing large unnecessary spaces), from there, there are options to obfusicate the code and other various features...

However, ive found a major bug in one of my options (for auto compiling the edited bit of code). What this should do is compile the code to either a form, module, or class module when you click the corresponding button. Form and module button works fine, but the class module button is having some issues.

I drop the normal module as follows

Private Sub button1_Click()
Open App.Path & "\" & sBas & "Module.bas" For Binary As #1
Put #1, , text1.Text
Close #1
MsgBox "Your code has been saved to regular module on working directory", vbInformation, "Done!"

And I edited that code accordingly to try and drop my class module,

Private Sub button2_Click()
Open App.Path & "\" & sCls & "Classmodule.cls" For Binary As #1
Put #1, , text1.Text
Close #1
MsgBox "Your code has been saved to class module on working directory", vbInformation, "Done!"

it does seem to indeed drop the class module as I would like, but when I attempt to open that class module VB6 seems to treat it as a regular module?

Any help to get it opening into an actual class module would be appreciated.

Recommended Answers

All 2 Replies

There are attributes in the various types of files that tell the environment what they are. Merely changing the file extension is insufficient.

Create a module and a class, then open them in NotePad, and see what the details are there.

As BrianWren is trying to point out, each file in vb6 has header information that is not displayed and it is this information that vb6 decodes to determine the actual type of file it is. VB6 does not just rely upon the file extension alone, it uses these headers, especailly for those files that represent a graphical interface like the frm file, and to see these headers, do as Brian suggests, open them in notepad.


Good Luck

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.