Receiving a function parameter

  • Thread starter Thread starter Yaron
  • Start date Start date
Y

Yaron

Hi,

I have a procedure in which I need to receive a parameter
which is actually the address of another procedure to
call. For example:

createEditBox(onSuccess, onFailure)

The onSuccess and onFailure paramaters are procedures to
call if the createEditBox function was successful or not.
However, I am unsure of what type to specify for
onSuccess and onFailure. Is this even possible in VB?

Thanks!

Yaron
 
Yaron said:
I have a procedure in which I need to receive a parameter
which is actually the address of another procedure to
call. For example:

createEditBox(onSuccess, onFailure)

The onSuccess and onFailure paramaters are procedures to
call if the createEditBox function was successful or not.
However, I am unsure of what type to specify for
onSuccess and onFailure. Is this even possible in VB?

You are looking for 'Delegates':

http://msdn.microsoft.com/library/en-us/vbcn7/html/vaconDelegateExample.asp

But, why not return a Boolean value indicating whether the function was
successful?
 
* "Yaron said:
I have a procedure in which I need to receive a parameter
which is actually the address of another procedure to
call. For example:

createEditBox(onSuccess, onFailure)

The onSuccess and onFailure paramaters are procedures to
call if the createEditBox function was successful or not.
However, I am unsure of what type to specify for
onSuccess and onFailure. Is this even possible in VB?

Keyword: "Delegate".

More info:

Delegate Statement (Visual Basic .NET)
<http://msdn.microsoft.com/library/en-us/vblr7/html/vastmDelegate.asp>

Delegates And Events Technology Sample (.NET Framework)
<http://msdn.microsoft.com/library/en-us/cpsamples/html/delegates_and_events_technology_sample.asp>

Delegate Usage Guidelines (.NET Framework General Reference)
<http://msdn.microsoft.com/library/en-us/cpgenref/html/cpcondelegateusageguidelines.asp>

I doubt that what you want to do is "good" design.
 
Thanks so much for the help...

Let me tell you exactly what I want to do... I have a
function which creates a textbox to edit fields in a
ListView (Details view). This function takes parameters
on the ListView to use, the item index, the column index,
and how many more fields after the current column to go
to. So, if we're beginning with field 4 in a ListView
called lstTest, and there are 3 more fields after 4 to
edit (5, 6, 7), it would look like this:

createEditField(lstTest, 1, 4, 3)

Now, the thing is, I want to add a final parameter to
this function that is actually a pointer to another
function to call once the last column has been reached
(in this case, 7), and finished with. So, can you give me
an example of how this would look?

Thanks!

Yaron
 
Back
Top