Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

VB.NET - 'WithEvents' variables cannot be typed as arrays - Now what?

Posted on 2008-10-17
4
811 Views
Last Modified: 2012-05-05
I have a class that I want to use several instances of... the class raises events to notify me of completed things.

everything works fine as 1 instance... however if i try to make an array of the class i get the error:

 'WithEvents' variables cannot be typed as arrays

is there a better way to do this?
0
Comment
Question by:mcainc
  • 2
4 Comments
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 22747147
Can you show the relevant code?
0
 

Author Comment

by:mcainc
ID: 22747166
Private WithEvents client() As IRCClient

this gives the error

Private WithEvents client As IRCClient

this works fine
0
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 22747172
mcainc

You'll have to use a collection of your objects, then use AddHandler on each item in the collection to handle each objects events.

Wayne
0
 
LVL 27

Accepted Solution

by:
Dabas earned 500 total points
ID: 22747173
Hello mcainc,

The way to overcome this is as per snippet

Regards,

Dabas
Private WithEvents client As IRCClient 
Private ClientArray() as IRCClient 
Somewhere else in your code, you might have something like: 
For Each client in ClientArray
...Raise your events here for the single client within the array
Next 
 

Open in new window

0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question