Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2008-10-17
4
Medium Priority
?
840 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 48

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 48

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 1500 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

The purpose of this article is to demonstrate how we can use conditional statements using Python.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

916 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