2012-01-02 20 views

cevap

19

inanıyorum Aşağıdaki kodu

Private Sub Jump(xStr as string) 
    Msgbox xStr & " is jumping." 
End Sub 

Private Sub Run(xStr as string) 
    Msgbox xStr & " is jumping." 
End Sub 

bu prosedür prosedürü yukarıda çağırmalıdır:
Bazı prosedürler aşağıda parametreleri olarak kullanılmak üzere oluşturulan İhtiyacınız olan şey için bir örnek.

Public Delegate Sub TestDelegate(ByVal result As TestResult) 

Private Sub RunTest(ByVal testFunction As TestDelegate) 

    Dim result As New TestResult 
    result.startTime = DateTime.Now 
    testFunction(result) 
    result.endTime = DateTime.Now 

End Sub 

Private Sub MenuItemStartTests_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItemStartTests.Click 

    Debug.WriteLine("Starting Tests...") 
    Debug.WriteLine("") 
    '================================== 
    ' Add Calls to Test Modules Here 

    RunTest(AddressOf Test1) 
    RunTest(AddressOf Test2) 

    '================================== 

    Debug.WriteLine("") 
    Debug.WriteLine("Tests Completed") 

End Sub 

tüm makale

bu yardımcı olur http://dotnetref.blogspot.com/2007/07/passing-function-by-reference-in-vbnet.html

Umut bulunabilir.

+0

Teşekkürler! Sorunum şimdi çözüldü. –

+0

+1, çünkü genellikle OP'den ziyade üçüncü tarafların oylarını kullanabiliyorlar ve üçüncü şahıslarım. – Lion

İlgili konular