TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Metin Erman
NA
9
0
Translating a Direct Event call in C# to VB.net...need a little help
Jun 17 2010 11:51 PM
OK, I have a situation where I am trying to use some code from C# and translate it to vb.net. I am stuck at a point where the C# code calls an Event directly. I know normally you would use the addhandler and raiseevent methods to do the same thing, but the way it is set up is slightly confusing to me. I am pretty sure once someone shows me the correct method, I will slap my head and say "Doh!", but I am tired of banging my head into the wall on this one. OK, here is the code in c# with the vb.net translation under it:
c#: public event EventHandler<SpriteCollisionEventArgs> SpriteCollision
vb: Public Event SpriteCollision As EventHandler(Of SpriteCollisionEventArgs)
c#: //Handle collision detection with itself
if (se.DetectCollisionSelf && SpriteCollision != null)
se.PerformSelfCollisionDetection();
vb: 'Handle collision detection with itself
If se.DetectCollisionSelf AndAlso SpriteCollision IsNot Nothing Then
se.PerformSelfCollisionDetection()
End If
The problem lies in the "if" statement on the event, which doesn't work in vb.net, saying "Public Event SpriteCollision is an event and cannot be called directly. Use a RaiseEvent statement to raise an event."
I am assuming I would call the raiseevent method and then run the if code in there, but then I am confused as to what I am running it on, since the event in c# is called directly with no arguments..
Any help would be appreciated...
Matt
Reply
Answers (
3
)
how to bind 2 tables with datagridview
cookies not passing the values from one page to another page