473,386 Members | 1,715 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,386 software developers and data experts.

Error converting from C# to VB.Net

Firstly, excuse me for my bad english.

Now to the point.

I converted a lot of code, and I had some errors in the conversion. There is one that I can't seem to figure it out:

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.

I've tried to use this
Expand|Select|Wrap|Line Numbers
  1. AddHandler anim.Completed, AddressOf endEvent
But obviously, I don't have a method called "endEvent".

This code works perfectly in C#, but I don't know how to figure it out in VB.Net



Edit:

Some time ago, this issue was discussed, but the solution code wasn't shown
Apr 10 '12 #1

✓ answered by Monomachus

The short answer is use Handles. Although I'm not a VB programmer, I might be wrong :)

http://msdn.microsoft.com/en-us/libr...(v=vs.71).aspx

Also you could try this.

Expand|Select|Wrap|Line Numbers
  1. AddHandler anim.Completed, endEvent
  2.  
http://msdn.microsoft.com/en-us/libr...ks95.aspx#Y200

2 1698
Monomachus
127 Expert 100+
The short answer is use Handles. Although I'm not a VB programmer, I might be wrong :)

http://msdn.microsoft.com/en-us/libr...(v=vs.71).aspx

Also you could try this.

Expand|Select|Wrap|Line Numbers
  1. AddHandler anim.Completed, endEvent
  2.  
http://msdn.microsoft.com/en-us/libr...ks95.aspx#Y200
Apr 10 '12 #2
Very thanks for the answer!

It works perfectly!
Apr 10 '12 #3

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

Similar topics

1
by: jaYPee | last post by:
I have created a stored procedure that contain this field (below) in order to meet certain criteria. But my problem is when I try to run the stored procedure I encounter an error "Error converting...
4
by: Saso Zagoranski | last post by:
Hi! I have created an SqlCommand object and I have set some parameters to it... One of the parameters is of the DateTime type; here is the code: sqlCommand.Parameters.Value =...
1
by: Andrew Baker | last post by:
this seems to be an SQL Server error but I cant work out how it is occuring. Itr is also after 3am and I cant keep working but need to demo by tomorrow. TIA. The code is: Private Sub...
0
by: rajmgopal | last post by:
Hello Everyone I am getting the following error when i try to insert a record into Sql Server 2005 from my VB 2005 application. sqlEx = {"Error converting data type numeric to numeric."} I...
2
by: Curious Trigger | last post by:
Hello, if have an asp.net web page with a detailsview. This detailsview uses a sqldatasource connecting to a sql server 2005 database with a select statement simliar to this one: SELECT...
1
by: ronca | last post by:
Error Syntax error converting the varchar value $568.25 to a column of data type Statement I'm using Select Top 1000 * From mass.dbo.dbo_MASS where _amount > 5000 Want only row with _amount...
4
by: darrel | last post by:
I'm getting this error: Arithmetic overflow error converting numeric to data type numeric. Triggered on this line of my code: objOleDbAdapter.Fill(DS, "rss") Everything works when this is...
2
by: Hulikal | last post by:
Hi, I using the following query select dateadd(s, 1185255439727, '01-01-1970 05:30:00') on MSSQL 2005. I get the error Arithmetic overflow error converting expression to data type...
0
by: bluepiper | last post by:
Hi everyone. I have created a linked server on SQL Server 2005 to access data from visual foxpro database. I execute a query Select * from OpenQuery(members, 'Select * from memfile') but Im...
5
AAPWM
by: AAPWM | last post by:
Hello My job is to extract data from my companies database with Crystal Reports, export that data to Excel, modify the data, save the data as "Text "tab delimited"", and upload to the database...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.