Re: can someone post a simple example of a class with a static method in vb6?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



On Fri, 10 Nov 2006 09:23:50 +0100, Sinna
<news4sinna_NOSPAM@xxxxxxxxxx> wrote:

<snip>

But how do implement functionality in a library that should be available
without instantiating a class?
E.g. when I want to extend/override built-in VB functionality it's just
so unwanted to have to use a class for it.
You can argue that I should use a module for that, but after a few years
of programming I've created a collection of common used functions.
I don't like to add them in each project because when a bug has been
discovered (happens some times :)) I have to recompile every piece of
code using the module. When grouping them in an external (in-process)
library I only have to recompile the library.

I see in the Object Browser that the VBA Library uses modules like
FileSystem. Is there any way to mimick that so that I can write
MyRunTime.FileSystem.MkDirEx(foo)?

Create a DLL and set the Class(es) in it to
Instancing: 6 GlobalMultiUse

The object will be automatically created

If it has a method called 'Test' then that can be referenced as:

DllInternalName.Test
or:
Test

You can then have other Classes that have
Instancing: 2 PublicNotCreatable

If you put this in Class2

Public Sub Class2Method()
MsgBox "Class2Method"
End Sub

You can then get:
DllInternalName.Test2.Class2Method

If Test2 in Class1 is a Property/Function that is like this :-

Public Property Get Test2() As Class2
Set Test2 = New Class2
End Property

I've just had a little play with creating a DLL like that, it works
quite nicely - but I would be nervous of AX compatibility.


.



Relevant Pages