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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Alan Adolphe
    New Member
    • Jan 2011
    • 2

    #1

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

    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.

    Code:
      Public Sub New()
            InitializeComponent()
    
            Me.Flip1Half.Completed += New EventHandler(AddressOf Flip1Half_Completed)
        End Sub
    error mesage:
    Error 8 'Public Event Completed(sende r As Object, e As System.EventArg s)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.

    thank's for any help .

    Alan
  • David Gluth
    New Member
    • Oct 2010
    • 46

    #2
    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
    Code:
     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]
    Code:
     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:

    Code:
    Dim myObj as new Flip1Half()
    
    addHandler myObj.Completed, AddressOf Procedure_to_run_when_event_occurs
    
    sub Procedure_to_run_when_event_occurs(sender as object,e as system.EventArgs)
    	Do something
    End sub

    Comment

    • Alan Adolphe
      New Member
      • Jan 2011
      • 2

      #3
      Hello David,

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

      Public Sub New()
      InitializeCompo nent()

      AddHandler Me.Flip1Half.Co mpleted, New EventHandler(Ad dressOf Flip1Half_Compl eted)

      End Sub

      thank's for replying,

      Alan

      Comment

      Working...