Delegates


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Delegates

  1. #1
    Patrick Long Guest

    Delegates

    I was looking at creating a simple generic sort routine yesterday. The
    routine would call a delegate function to do the "what is greater than what"
    comparison. Seems simple enough but whenever I have what looks like a
    correct delegate signature declared in my form the form will not display in
    the IDE and I get an error.

    Delegate Function IsGreater(ByVal v1 As Integer, ByVal v2 As Integer) As
    Boolean

    The error is "unexpected token 'Function' of type 'KW_Function' at line 61
    column 14. Expected a 'KW_Sub' token. Unsurprisingly if I change from a
    function to a sub it does not error. Is there something wrong with my using
    a function?

    This is the delegate signature. Could someone try putting this in a windows
    application and then try and use it in a form in the IDE.

    Thanks

    Pat Long




  2. #2
    Phil Weber Guest

    Re: Delegates

    > Is there something wrong with my using a function?

    Pat: I'm not sure what the problem is (might the name IsGreater already be
    defined elsewhere?), but there's an example of exactly what you're trying to
    do at http://www.freevbcode.com/ShowCode.Asp?ID=2150 .
    ---
    Phil Weber



  3. #3
    Mark Hurd Guest

    Re: Delegates

    "Patrick Long" <Patrick_long@csi.com> wrote in message
    news:3ade8be0$1@news.devx.com...
    >
    > Delegate Function IsGreater(ByVal v1 As Integer, ByVal v2 As Integer) As
    > Boolean
    >
    > The error is "unexpected token 'Function' of type 'KW_Function' at line 61
    > column 14. Expected a 'KW_Sub' token. Unsurprisingly if I change from a
    > function to a sub it does not error. Is there something wrong with my

    using
    > a function?


    What you're describing sounds like the WinForms Form Editor (specifically
    its parser) failing to understand a function delegate. It has similar
    problems with some attributes. If you think it is valid code try to compile
    it. If I'm right, for the rest of beta 1 you'll have to either not use the
    form editor or shift the code to another file.

    >
    > Thanks
    >
    > Pat Long
    >


    Regards,
    Mark Hurd, B.Sc.(Ma.) (Hons.)



  4. #4
    Bill McCarthy Guest

    Re: Delegates

    Hi Patrick,

    I believe that is actually a known bug with Beta 1, and has been fixed for
    later builds.


    "Patrick Long" <Patrick_long@csi.com> wrote in message
    news:3ade8be0$1@news.devx.com...
    > I was looking at creating a simple generic sort routine yesterday. The
    > routine would call a delegate function to do the "what is greater than

    what"
    > comparison. Seems simple enough but whenever I have what looks like a
    > correct delegate signature declared in my form the form will not display

    in
    > the IDE and I get an error.
    >
    > Delegate Function IsGreater(ByVal v1 As Integer, ByVal v2 As Integer) As
    > Boolean
    >
    > The error is "unexpected token 'Function' of type 'KW_Function' at line 61
    > column 14. Expected a 'KW_Sub' token. Unsurprisingly if I change from a
    > function to a sub it does not error. Is there something wrong with my

    using
    > a function?
    >
    > This is the delegate signature. Could someone try putting this in a

    windows
    > application and then try and use it in a form in the IDE.
    >
    > Thanks
    >
    > Pat Long
    >
    >
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center