Need help defining an event handler...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • SpreadTooThin

    Need help defining an event handler...

    I'm running Visual Basic Express Editon 2008.
    I have a project that references an OLE object called MyObject
    That object fires events.
    How do I declare the event handler in the Main Form class
    implementation?

    Public Class Form1

    Dim WithEvents server as MyObject.MyServ er

    ? How do I declare the event handler?

    End Class

    I was told that it should be in the IDE but I don't see anything that
    would help me declare this method in my code.
  • kimiraikkonen

    #2
    Re: Need help defining an event handler...

    On Nov 20, 7:45 pm, SpreadTooThin <bjobrie...@gma il.comwrote:
    I'm running Visual Basic Express Editon 2008.
    I have a project that references an OLE object called MyObject
    That object fires events.
    How do I declare the event handler in the Main Form class
    implementation?
    >
    Public Class Form1
    >
       Dim WithEvents server as MyObject.MyServ er
    >
    ?  How do I declare the event handler?
    >
    End Class
    >
    I was told that it should be in the IDE but I don't see anything that
    would help me declare this method in my code.
    As you're using a form, you can also subscribe its events in your
    Form1.Designer. vb partial class like:
    Friend WithEvents server As MyObject.MyServ er

    To handle, use Handles clause:
    Like that:


    Public Class Form1

    ' In your form
    ' Assuming it has a click method
    Private Sub MyServer_Click( ByVal sender As Object, _
    ByVal e As System.EventArg s) Handles MyServer.Click

    End Class


    ....of course i cannot test it as the object is custom (not included in
    framework, thus we don't know what events and signatures it expose),
    but hope that gives some idea.

    Hope this helps,

    Onur Güzel

    Comment

    • Lloyd Sheen

      #3
      Re: Need help defining an event handler...


      "SpreadTooT hin" <bjobrien62@gma il.comwrote in message
      news:c2afc83e-c298-4054-8b92-7442d05ecf04@k3 6g2000pri.googl egroups.com...
      I'm running Visual Basic Express Editon 2008.
      I have a project that references an OLE object called MyObject
      That object fires events.
      How do I declare the event handler in the Main Form class
      implementation?
      >
      Public Class Form1
      >
      Dim WithEvents server as MyObject.MyServ er
      >
      ? How do I declare the event handler?
      >
      End Class
      >
      I was told that it should be in the IDE but I don't see anything that
      would help me declare this method in my code.

      Ok:

      1. Open form with the OLE object in the designer
      2. Select the object on the form
      3. Go to properties (F4)
      4. In the properties window click the lightning bolt at on the properties
      window toolbar
      5. You should now see a list of all the events which the dot.net
      framework knows about for the object
      6. Double click in the dropdown box to the right of the Event name

      This should create a stub for you in your code.

      LS

      Comment

      • John Whitworth

        #4
        Re: Need help defining an event handler...


        "Lloyd Sheen" <a@b.cwrote in message
        news:OtutI2zSJH A.5344@TK2MSFTN GP06.phx.gbl...
        >
        1. Open form with the OLE object in the designer
        2. Select the object on the form
        3. Go to properties (F4)
        4. In the properties window click the lightning bolt at on the
        properties window toolbar
        5. You should now see a list of all the events which the dot.net
        framework knows about for the object
        6. Double click in the dropdown box to the right of the Event name
        >
        This should create a stub for you in your code.
        But that just handles simple, built-in events. I think that the OP wanted a
        custom event that could be picked up by other forms/objects.

        JW

        Comment

        • Lloyd Sheen

          #5
          Re: Need help defining an event handler...


          "John Whitworth" <sexyjw@g_eeeee eeeeeeee_mail.c omwrote in message
          news:CB2265FC-8938-4B9C-90FD-485BB0A8BB97@mi crosoft.com...
          >
          "Lloyd Sheen" <a@b.cwrote in message
          news:OtutI2zSJH A.5344@TK2MSFTN GP06.phx.gbl...
          >>
          >1. Open form with the OLE object in the designer
          >2. Select the object on the form
          >3. Go to properties (F4)
          >4. In the properties window click the lightning bolt at on the
          >properties window toolbar
          >5. You should now see a list of all the events which the dot.net
          >framework knows about for the object
          >6. Double click in the dropdown box to the right of the Event name
          >>
          >This should create a stub for you in your code.
          >
          But that just handles simple, built-in events. I think that the OP wanted
          a custom event that could be picked up by other forms/objects.
          >
          JW
          An event is an event. There are no custom events just events. If an object
          on a form has PUBLIC events they will show in the list unless there is an
          attribute (don't know what it is offhand) that will stop the event from
          showing in the list.

          The OLE object dropped on the form has to be of a type that exposes the
          event.

          LS

          Comment

          Working...