By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,239 Members | 1,493 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,239 IT Pros & Developers. It's quick & easy.

delegates in classes

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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

"Robert Batt" <ro********@yahoo.co.uk> wrote in message
news:0c****************************@phx.gbl...
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

Nov 20 '05 #2

P: n/a
You need to declare a delegate like this.

Public Delegate Sub DecimalToCurrencyString(ByVal sender As Object, ByVal
cevent As ConvertEventArgs)


Robert Batt wrote:
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


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com
Nov 20 '05 #3

P: n/a
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
"Robert Batt" <ro********@yahoo.co.uk> wrote in message
news:0c****************************@phx.gbl...
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

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.