Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
As for the custom Form i declare it this way;
Dim WithEvents Ev As New MyDll.MyClass


but when i try to public it, to work plus on another Form, the Events "Ev " isnt displayed on the other Form.
How i can manage this i tried many options i played with shared, public, friend...
but with no result, is it even possible?
Posted
Comments
Sergey Alexandrovich Kryukov 12-Nov-12 0:15am    
What do you mean "displayed"? Why do you think it should be "displayed"? What are you trying to achieve?
--SA

1 solution

You only use Dim inside a method.

In your case, at the class leve, you remove the Dim and replace it with Public or Private depending on the visibility you want.
 
Share this answer
 
Comments
[no name] 11-Nov-12 12:15pm    
I have tried it with public too but no result, please re-read my question, thanks
Dave Kreskowiak 11-Nov-12 13:01pm    
To get it to work on multiple forms, I'm guessing it would have to be put in a Module, not a class.

I'm not really sure as, in 30+ years of writing code, I've never had a need to do what you're doing.

[no name] 11-Nov-12 16:44pm    
30 years of coding, damn youre a killer bro. to my question i have a dll file with a class where therein will be raised some events. Now i have in my current project 2 windows forms, and i need on both forms to get the raised events of that "mydll.myclass" trying to declare the same dll from both forms it gave me overflow errors since i use win APIs. Now i thought i only declare the withevents as public to access them from overall, but thats not the case, in form1 it shows it as expected but on the other form the event(which are shown in blue) is missing? that was my question.
For example i write this;
Dim WithEvents Ev As New mydll.myclass
and in same moment above on the current forms topbar there is shown the class of the dll in blue color and a bit to the right, i can chose for example which event to call, e.g like (example of Timer()) gotfocus, keypressed you know what i mean, and thats what i want to achieve without declaring it 2 times for each form since the app crashes(overflow exception) because of APIs i use. i want to achieve the same infos but synchronyosly on both forms. i want not to get ugly declaring variables of form2 from form1.
Maybe this is not the best descriptipon of my problem but i hope you got it
Thanks for the reply and sorry for the inconvienence
Dave Kreskowiak 11-Nov-12 17:13pm    
You're describing things like I can see your monitor. The description isn't complete at all.

But, from what it sounds like, you could declare the object in a Module and make it public, then you'll have to wire up the event handlers in your forms yourself. You're not going to get the IDE to help you do this as the object is visible to the forms code, but it is not part of either form.

Just Google for "AddHandler vb.net" and you'll see how to do it.
[no name] 11-Nov-12 17:35pm    
Thanks i will take a look on that method

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900