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

raise an event error when converting c# code to vb.net

P: 2
Hi, I have converted C# code to vb.net using the online converter tools. One error messages I can't seem to figure out. Any ideas or help is appreciated.

Expand|Select|Wrap|Line Numbers
  1.   Public Sub New()
  2.         InitializeComponent()
  3.  
  4.         Me.Flip1Half.Completed += New EventHandler(AddressOf Flip1Half_Completed)
  5.     End Sub
  6.  
  7.  
error mesage:
Error 8 '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.

thank's for any help .

Alan
Jan 10 '11 #1

✓ answered by David Gluth

There really isnít enough information here to figure out what is supposed to be happening.

VB event basics:

Declare an event: - [from your error message it looks like this is in there somewhere
Expand|Select|Wrap|Line Numbers
  1.  Public Event Complete(byVal sender as Object,ByVal e as System.EventArgs)
Raise an event: - [I think this is probably somewhere in your code as well]
Expand|Select|Wrap|Line Numbers
  1.  RaiseEvent Complete(me,args)
The line is that is causing you a problem is an attempt to dynamically assign a sub routine to the event.

This is where the lack of code become a problem for us to guess at. Typically the code would look like this:

Expand|Select|Wrap|Line Numbers
  1. Dim myObj as new Flip1Half()
  2.  
  3. addHandler myObj.Completed, AddressOf Procedure_to_run_when_event_occurs
  4.  
  5. sub Procedure_to_run_when_event_occurs(sender as object,e as system.EventArgs)
  6.     Do something
  7. End sub
  8.  

Share this Question
Share on Google+
2 Replies


P: 46
There really isnít enough information here to figure out what is supposed to be happening.

VB event basics:

Declare an event: - [from your error message it looks like this is in there somewhere
Expand|Select|Wrap|Line Numbers
  1.  Public Event Complete(byVal sender as Object,ByVal e as System.EventArgs)
Raise an event: - [I think this is probably somewhere in your code as well]
Expand|Select|Wrap|Line Numbers
  1.  RaiseEvent Complete(me,args)
The line is that is causing you a problem is an attempt to dynamically assign a sub routine to the event.

This is where the lack of code become a problem for us to guess at. Typically the code would look like this:

Expand|Select|Wrap|Line Numbers
  1. Dim myObj as new Flip1Half()
  2.  
  3. addHandler myObj.Completed, AddressOf Procedure_to_run_when_event_occurs
  4.  
  5. sub Procedure_to_run_when_event_occurs(sender as object,e as system.EventArgs)
  6.     Do something
  7. End sub
  8.  
Jan 13 '11 #2

P: 2
Hello David,

Yes you are correct, actualy i got it to run a couple days ago with the the following;

Public Sub New()
InitializeComponent()

AddHandler Me.Flip1Half.Completed, New EventHandler(AddressOf Flip1Half_Completed)

End Sub

thank's for replying,

Alan
Jan 14 '11 #3

Post your reply

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