Is there a way to check if the / Sub function is available in VB6?

We have several Subs (e.g. WriteErrorToLog and some AutomatedTesting) that I would like to make optional if we want to reuse the component.

I would like to be able to do something like if AddressOf (Sub) is valid and then execute Sub.

+3
source share
1 answer

A structured way to do this is to make an auxiliary / functional part of the interface. Now you can let two different classes implement this interface, one of which provides empty implementations, and the other - real logic.

, , . , .

Dim obj As IMyInterface
Set obj = New EmptyImplementationClass

Call obj.SomeSub() ''// Executes no code

Set obj = New RealImplementationClass

Call obj.SomeSub() ''// Executes the real implementation
+3

Source: https://habr.com/ru/post/1748741/


All Articles