how to have an array of browsers in VB (Dim WithEvents o_IE As InternetExplorer / Set o_IE = New InternetExplorer)

Hello !

I have a project controlling IE. So far it works fine.
Now I want to add a second instance (or even several).

I was wondering if I can put them all into an array (and how).

Thank you for any idea !

Dim test(3) As String; <- works
Dim WithEvents o_IE As InternetExplorer;<- works too
Dim WithEvents o_IEarray(3) As InternetExplorer ,<- does not (syntax error, expecting AS)

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Should be:
Dim o_IEarray(3) As InternetExplorer

Open in new window

Wayne Taylor (webtubbs)Commented:
If you have an array of InternetExplorer's, don't use WithEvents, but add your event handlers with AddHandler.

Also, I would use a generic list, of type InternetExplorer....

        Dim IEList As New List(Of InternetExplorer)
        Dim IE As InternetExplorer '= however you get the IE object
        AddHandler IE.DocumentComplete, AddressOf IE_DocumentComplete

...where IE_DocumentComplete is the routine to handle the DocumentComplete event of the IE object.

Wayne Taylor (webtubbs)Commented:
sorry, just realised your are using VB6. Ignore my comment above.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

DistributedServicesAuthor Commented:
Hi elimesika !

Of cause that work's but how do I get the events?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DistributedServicesAuthor Commented:
Thank you, elimesika, for your help about raising events in VB6.

On I did not find, how to receive an event (normally a function is been called when an event raises).  

Do you have any idea how to dim an array of browsers with events, like

Dim WithEvents o_IEarray(3) As InternetExplorer

Sorry for the delay (have lot of work to do), will look at it ASAP...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.