Solved

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

Posted on 2008-10-17
4
824 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
[X]
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
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video teaches viewers about errors in exception handling.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

623 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