473,382 Members | 1,238 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

RaiseEvent in vb.net

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
4 14803
zip929
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
9,735 Expert Mod 8TB
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
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
ofek
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

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

Similar topics

1
by: Guille | last post by:
Hi all! I'm having some weird behaviour in a .NET application i'm developing. I'll try to explain: I've created a Class that wraps an asynchronous socket. When connect callback is called, i...
8
by: Nicolas | last post by:
How do I do a RaiseEvent in csharp I'm ok in VB but csharp confused me a lot. ******* code ******** private FileSystemWatcher watcher = new FileSystemWatcher(); public delegate void...
2
by: Carl tam | last post by:
Hi everyone, I got a quite interesting problem myself and got stuck. I have an aspx page with a windows user control with it. in the Windows Control. I have a RaiseEvent statement, say...
20
by: Bob Day | last post by:
Using VS 2003, VB, MSDE... There are two threads, A & B, that continously run and are started by Sub Main. They instantiationsl of identical code. Thread A handles call activity on telephone...
2
by: Lim | last post by:
I've developed a program that raise an event. This program works fine on a Windows 2000 Professional PC. However when I try to run the program on a Windos XP Professional PC, the program will not...
2
by: dmoonme | last post by:
I'm trying to rename some files in a directory. Pretty basic stuff - renaming the files works fine but the problem I have is updated the text in textbox. All I want to do is appendtext to a...
7
by: Onokiyo | last post by:
Hello, I have the code below and somehow the message from RaiseEvent doesn't pop up at all. Can someone help me please? '------CODE '------/form1.vb/VB2005/Framework20--------- Imports...
3
by: Martin | last post by:
Hi all, I'm having a problem when trying to raise an event in my custom control when a toolstripbutton enable state changes. The problem is that although the code to raise the event executes, my...
1
by: Terry Olsen | last post by:
I have a program with a couple of long running processes that i'm calling on a separate thread. When the process is completed, I want to raise an event to tell the main thread that it's done. I...
10
by: hzgt9b | last post by:
Using VS2005, VB.NET, I am developing a windows app. The application opens a couple of forms. While the forms are open I want to raise some events, such as logging errors - but I call RaiseEvent,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.