To port the PseudoEventClassCode to a Visual Basic (VB) 6.0 project, follow these steps:
- Cut and paste the VBScript code in a class module that you've opened in a new project.
- Move all the variable declarations to the top of the file.
- Comment the line that uses the Eval function because VBA doesn't support Eval.
- Make sure you've explicitly declared the VBScript array arrFile. Using Redim to reinitialize arrays that you haven't explicitly declared causes problems in VB 6.0. Initially declaring arrays with Dim avoids any problems.
- Copy and insert the code that executes after Class_Initialize to the proper VB handler (still calling this code Class_Initialize) to make VB 6.0 recognize and execute that code. You must sink the event through the VB IDE.
When you’ve completed these steps, the class works in VBA code. You must rethink only one aspect: the event handling. Although VBScript doesn’t natively support events, VB provides a specific programming interface to handle and raise events. Thus, you need to adapt the VBScript code accordingly.