I have an application where in I have created two class modules. Both the class modules have same properties and same methods but the implementation is different. As both the classes have same methods and properties I am using the same Object to instantiate the classes like this
VB Code:
'In general declarations
Dim objTemp As Object
'in a procedure
If SomeCondition Then
Set objTemp = New Class1
Else
Set objTemp = New Class2
End If
'After some processing
Set objTemp = Nothing
After instantiating the object I will use objTemp in different methods. This instantiation happens in a timer event.
This does not give any Compile or Run Time Errors, but the application stops working either when it is before the Instantiation code or just at this line Although I am not sure if this is causing any problem but I would like to know are there any drawbacks of using this type of code.
Any comments and suggestions are welcome.