|
-
Apr 4th, 2004, 03:29 PM
#1
Thread Starter
New Member
How to include a function call as a parameter in another function?
For example:
VB Code:
Public Function RefreshPages(ctl1 as control, ctl2 as control, ctl3 as control, sub_name as ??????)
ctl1.do something
ctl2.do something
ctl3.do something
'now call the sub or function that was passed as a paramater
sub_name()
End Function
So whenever i finish doing whatever with the controls that the function was passed, i can then call the sub or function that was also passed.
Last edited by C_Huegel; Apr 4th, 2004 at 03:33 PM.
-
Apr 4th, 2004, 03:51 PM
#2
Do a search on Delegates. This will limit you to a method with no parameters since you wont know what to pass in but it is very easy.
Something like this:
VB Code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
RefreshPages(Button1, Button2, lblName, AddressOf callback)
End Sub
Public Delegate Sub RefreshPageCallBack()
Public Function RefreshPages(ByVal ctl1 As Control, ByVal ctl2 As Control, ByVal ctl3 As Control, ByVal callback As RefreshPageCallBack)
ctl1.Text = String.Empty
ctl2.Text = String.Empty
ctl3.Text = String.Empty
'now call the sub or function that was passed as a paramater
callback.Invoke()
End Function
Public Sub callback()
MsgBox("called")
End Sub
Last edited by Edneeis; Apr 4th, 2004 at 03:58 PM.
-
Apr 4th, 2004, 03:54 PM
#3
Thread Starter
New Member
Sweet, Thanks.
-
Apr 4th, 2004, 03:55 PM
#4
Frenzied Member
I've never personally seen or heard of that. but, I'm no expert either. What I might do is use a SELECT statement and when certain paramerters are met, have certain functions launch.
That's just ONE way though. my .02
I'm anxious to see what the verterans have to suggest!!
Last edited by Andy; Apr 4th, 2004 at 04:14 PM.
-
Apr 4th, 2004, 03:56 PM
#5
Thread Starter
New Member
Delegates is just what I was looking for... perfect.
-
Apr 4th, 2004, 04:18 PM
#6
Frenzied Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|