Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Functions

Status
Not open for further replies.

oddball

Technical User
Mar 17, 2000
64
GB
Can you call a Function (rather than a sub) from the OnIndexChanged event of a dropdownlist control. If you can why do i get this error:

BC30408: Method 'Public Function ProdDefList() As System.Collections.ICollection' does not have the same signature as delegate 'Delegate Sub EventHandler(sender As Object, e As System.EventArgs)'.
 
Could you post your code up for us to have a look at?
:)

Jack
 
You could call a function, but why? Where will your return value go? If you want it to be a function, then just give it the same signature:

Public Function ProdDefList(o as object, e as eventArgs)

but to my point, when using a function, this function should return a value, so:

Public Function ProdDefList(o as object, e as eventArgs) as integer

or whatever just doesn't make sense, since you'd be sending the return value off into deep space. Typically, just make it a sub with the handles keyword after the sub:

Protected Sub ProdDefList(o as object, e as eventArgs) handles myListBox.selectedIndexChanged

Maybe I'm missing your point. What's the reasoning behind wanting to use a function instead of a sub?

paul
penny1.gif
penny1.gif
 
Paul: could be that he doesn't know the ins/outs of vb.net
(thats not a slag oddball, just noticed you listed yourself as a Technical User instead of a Programmer).

Oddball: If Paul is bang on about what you're trying to do (i.e. return some value), you're better off assigning whatever value you're looking for to either a session variable, adding it to the viewstate, or even just dealing with the data inside the event.

A function needs to be called from something that can use the return value. If your ddl index changes, thats really an event; another bit of code isn't calling it.

If we're on the same wavelength, and you need further tips on the Session/Viewstate, etc. just let us know
:)

Jack
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top