|
-
Oct 4th, 2006, 06:57 AM
#1
Thread Starter
Lively Member
Problem with converting code
from C# to VB. I have the code working fine in C#.
C#
Code:
interceptor = new MessageInterceptor();
interceptor.InterceptionAction = InterceptionAction.NotifyAndDelete;
interceptor.MessageReceived += new MessageInterceptorEventHandler(OnSmsReceived);
VB
VB Code:
interceptor = New MessageInterceptor()
interceptor.InterceptionAction = InterceptionAction.NotifyAndDelete
interceptor.MessageReceived += New MessageInterceptorEventHandler(OnSmsReceived)
I get errors in VB on line 3 saying I have to use a RaiseEvent statement for MessageRecevied. I am not sure how to do this if anyone can help.
Thanks
-
Oct 4th, 2006, 07:18 AM
#2
Re: Problem with converting code
If we as software developers cannot consult help documentation how can we expect our users to do so?
http://msdn2.microsoft.com/en-us/library/fwd3bwed.aspx
Last edited by jmcilhinney; Oct 4th, 2006 at 07:22 AM.
-
Oct 4th, 2006, 08:15 AM
#3
Thread Starter
Lively Member
Re: Problem with converting code
Yeah thanks. I did actually look at some documentation but still don't understand how to do it. I understand that because MessageReceived is an event you have to RaiseEvent it rather that call it directly, so I would therefore put the RaiseEvent infront of it. I'm still doing something wrong though.
-
Oct 4th, 2006, 08:26 AM
#4
Re: Problem with converting code
The short-form VB equivalent is:
AddHandler interceptor.MessageReceived, AddressOf OnSmsReceived
You could also code:
AddHandler interceptor.MessageReceived, New MessageInterceptorEventHandler(AddressOf OnSmsReceived)
-
Oct 4th, 2006, 08:34 AM
#5
Thread Starter
Lively Member
Re: Problem with converting code
So it's just like when you create a control at run time and you want to use its Click event for instance.
Is this the same as Raising and event then?
Thanks very much
-
Oct 4th, 2006, 08:41 AM
#6
Re: Problem with converting code
No - the original C# code you posted does not raise an event. It wires up the event handler.
-
Oct 4th, 2006, 04:59 PM
#7
Re: Problem with converting code
Hmmm... I guess I could have read the code too. Odd that it would point you to RaiseEvent when you're trying to handle an event rather than raise one. The page I linked to does include a link to the AddHandler statement and MSDN also includes pages many topics dedicated to raising an handling events.
http://search.msdn.microsoft.com/sea...andling+Events
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|