delegates in classes

  • Thread starter Thread starter Robert Batt
  • Start date Start date
R

Robert Batt

Hello,
I'm trying to modularize the code in my forms by
putting some procedures and delegates in a seperate class.
However I try to put a delegate with the following header
in a class.
Public Sub DecimalToCurrencyString(ByVal sender As
Object, ByVal cevent As ConvertEventArgs)


However I get a syntax error on ConvertEventArgs, saying
it is not declared. the class will not let me import
system.windows.forms for some reason.
Any ideas if or how I can get around this, or are
delegates just not allowed in classes

Regards
Robert
 
Robert,
Are you talking a Class or a Class Library?

As a Class within your current Project should not be causing your problems,
it sounds like you defined a new Class in a new Class Library.

Remember that Imports go outside the Class statement. If this new Class is
in a Class Library you need to reference (Project - Add References) the
assembly where the namespace is defined. Both the namespace & assembly for a
Class is defined in the Requirements section of the info topic on the class
in MSDN.

As far as where to define a delegate itself, it can be defined inside or
outside of a Class depending on your "requirements".

Hope this helps
Jay
 
You need to declare a delegate like this.

Public Delegate Sub DecimalToCurrencyString(ByVal sender As Object, ByVal
cevent As ConvertEventArgs)
 
Delegates can be defined in namespaces... so there's no problem where you
can define them, however, you haven't correctly declared the delegate, you
need to use the "Delegate" clause...

Public Delegate Sub DecimalToCurrencyString(...)

--
HTH,
-- Tom Spink, Über Geek

Woe be the day VBC.EXE says, "OrElse what?"

Please respond to the newsgroup,
so all can benefit
 
Back
Top