Passing a Sun address

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

    #1

    Passing a Sun address

    Now I do

    SyatemSub(Addre ssOf Somesub)


    I want to define a sub as follows


    Sub2(???)
    SystemSub(???)
    End Sub

    And call it thus:
    Sub2 (Address of SomeSub)

    Can I do that?


  • Jay B. Harlow [MVP - Outlook]

    #2
    Re: Passing a Sun address

    **Developer**
    Do you mean you want to do something like:

    ' Define what some sub should look like
    Public Delegate Sub ASub(ByVal value As Integer)

    Public Sub Main()
    ' pass the "address" of SomeSub
    Sub2(AddressOf SomeSub)
    End Sub

    Public Sub Sub2(ByVal asub As ASub)
    ' we already have the "Address" so just pass it
    SystemSub(asub)
    End Sub

    Public Sub SystemSub(ByVal asub As ASub)
    asub.Invoke(10)

    ' Invoke is optional, so you can also use:
    asub(10)

    End Sub

    Public Sub SomeSub(ByVal value As Integer)
    ' Do something exciting with value.
    End Sub


    --
    Hope this helps
    Jay [MVP - Outlook]
    T.S. Bradley - http://www.tsbradley.net


    " **Developer**" <REMOVEdevelope r@a-znet.com> wrote in message
    news:uS04YaQ0FH A.3488@TK2MSFTN GP09.phx.gbl...
    | Now I do
    |
    | SyatemSub(Addre ssOf Somesub)
    |
    |
    | I want to define a sub as follows
    |
    |
    | Sub2(???)
    | SystemSub(???)
    | End Sub
    |
    | And call it thus:
    | Sub2 (Address of SomeSub)
    |
    | Can I do that?
    |
    |


    Comment

    • **Developer**

      #3
      Re: Passing a Sun address

      Yes

      It took a while because the SystenSub I had in mind was
      Dim t As New Thread(?)

      Now I know your example applies since there is a Delegate (ThreadStart) that
      I can use.

      Thanks



      Public Shared Function MakeAbortThread (ByVal threadCode As ThreadStart...)
      As Thread

      Dim t As New Thread(threadCo de)

      t.Start()

      -snip-

      Return t

      End Function

      "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP @tsbradley.net> wrote in
      message news:ecn9XfQ0FH A.3812@TK2MSFTN GP09.phx.gbl...[color=blue]
      > **Developer**
      > Do you mean you want to do something like:
      >
      > ' Define what some sub should look like
      > Public Delegate Sub ASub(ByVal value As Integer)
      >
      > Public Sub Main()
      > ' pass the "address" of SomeSub
      > Sub2(AddressOf SomeSub)
      > End Sub
      >
      > Public Sub Sub2(ByVal asub As ASub)
      > ' we already have the "Address" so just pass it
      > SystemSub(asub)
      > End Sub
      >
      > Public Sub SystemSub(ByVal asub As ASub)
      > asub.Invoke(10)
      >
      > ' Invoke is optional, so you can also use:
      > asub(10)
      >
      > End Sub
      >
      > Public Sub SomeSub(ByVal value As Integer)
      > ' Do something exciting with value.
      > End Sub
      >
      >
      > --
      > Hope this helps
      > Jay [MVP - Outlook]
      > T.S. Bradley - http://www.tsbradley.net
      >
      >[/color]


      Comment

      Working...