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:
  1. 'In general declarations
  2. Dim objTemp As Object
  3.  
  4. 'in a procedure
  5. If SomeCondition Then
  6.     Set objTemp = New Class1
  7. Else
  8.     Set objTemp = New Class2
  9. End If
  10. 'After some processing
  11. 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
VB Code:
  1. Set objTemp = Nothing
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.