how to pass a function name as a argument into another one function ?

how to pass a function name as a argument  into another one function and  how to run this passed function name into passed function.
for example :
public class first
public sub test
msgbox "hellow"
end sub
end class

public class  second
public sub well
dim t as new first
GetAndRunMethod(addressOf t.test())
end sub
public sub GetAndRunMethod(dim GetFun)
call GetFun
end sub
end class

how to achieve my above purpose ?
tamilsoftAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CodeCruiserCommented:
Examples here

http://dotnetref.blogspot.com/2007/07/passing-function-by-reference-in-vbnet.html

stackoverflow.com/questions/2734166/vb-net-function-that-takes-other-functions-as-a-parameter-and-executes-them
0
nepaluzCommented:
you already have it, initialize the class and reference the sub you need to call,in your case:
t.test()

Open in new window

will run the sub in the first class
0
käµfm³d 👽Commented:
Instead  of "Dim GetFun", try "ByVal GetFun As Action". This is essentially what CodeCruiser's first link discusses. The difference is:  use Func when you have a Function you want to pass; use Action when you have a Sub you want to pass.

Also, remove the parentheses when you pass the function.

i.e.

GetAndRunMethod(addressOf t.test)

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

tamilsoftAuthor Commented:

according  experts "codecruiser" reply, following statements are not accepted

Public Sub passFun(ByVal a As Func(Of T))

End Sub

how to use it ?
0
käµfm³d 👽Commented:
Because your "Sub Test" does not return a value, you need to use an Action, not a Func. In other words:

Public Sub passFun(ByVal a As Action)

End Sub

Open in new window

0
tamilsoftAuthor Commented:
ok.  kaufmed.
"public sub passfun" works perfectly.

public function add(a as integer, b as integer) as integer
return a+b ;
end sub

how to pass and return  Add(2,3) into function ?
0
käµfm³d 👽Commented:
I answered this in https:#a37291017
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.