By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,652 Members | 1,358 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,652 IT Pros & Developers. It's quick & easy.

RaiseEvent in vb.net

P: 2
Hi,
I am a newbie to vb.net, I have converted C# code to vb.net using the online converter tools. I have got rid of all the error messages but there is one I can't seem to figure out. Any ideas or help is appreciated.

Expand|Select|Wrap|Line Numbers
  1. Private Function MakeAnimation(ByVal [to] As Double, ByVal duration As Double, ByVal endEvent As EventHandler) As DoubleAnimation
  2.             Dim anim As New DoubleAnimation([to], TimeSpan.FromMilliseconds(duration))
  3.             anim.AccelerationRatio = 0.2
  4.             anim.DecelerationRatio = 0.7
  5.             If endEvent IsNot Nothing Then
  6.                 anim.Completed += endEvent
  7.             End If
  8.             Return anim
  9.         End Function
The line marked in bold (above) is where this error (shown below) comes up

Error 1 'Public Event Completed(sender As Object, e As System.EventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event. C:\Documents and Settings\Temporary Projects\FishEyePanel.vb 292 17


Many Thanks
@nand
Dec 11 '08 #1
Share this Question
Share on Google+
4 Replies


P: 1
Try using:
AddHandler anim.Completed , Addressof endEvent

endEvent will need to have the same signature as the anim.Completed Event
i.e. (sender As Object, e As System.EventArgs)'

Dave
Dec 11 '08 #2

Frinavale
Expert Mod 5K+
P: 9,731
You cannot directly assign an event handler like you are currently doing so.

You need to use the AddHandler statement to dynamically assign an event handler.
Dec 11 '08 #3

P: 2
Hi Zip929 and Frinavale,
You guys rock. Thank you for the very quick pointers. Answer accepted. Please close this post.

Many Thanks
@nand
Dec 12 '08 #4

P: 4
Hi,
If that's where the error is, I would simply put there:
anim.Completed = anim.Completed + endEvent
It might just work...

Best regards,
Ofek Cohany
<link removed>
Dec 14 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.