VB.NET 1.1 - problems using delegate

G

Guest

Hi,

I have defined a delegate like this:

Delegate Sub ShowProgressDelegate(ByVal dblPctDone As Integer, ByVal iMax As
Integer, ByRef bCancel As Boolean)

Private Sub cmdExecute_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdExecute.Click
Dim dblPctDone As Double
Dim iMax As Integer = 0

Dim ShowProgress As ShowProgressDelegate

.....

ShowProgress = AddressOf ShowProgress(dblPctDone, iMax, False)


I get this compile error:
'AddressOf' operand must be the name of a method; no parentheses are needed.

how do I fix that please?

thanks

Philip
 
V

VJ

it is more like below..

Delegate Sub ShowProgressDelegate(ByVal dblPctDone As Integer, ByVal
iMax As Integer, ByRef bCancel As Boolean)

Private Sub cmdExecute_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) 'Handles cmdExecute.Click
Dim dblPctDone As Double
Dim iMax As Integer = 0
Dim ShowProgress As ShowProgressDelegate
ShowProgress = AddressOf ShowProgress42 dblPctDone, iMax, False
End Sub

Private Sub ShowProgress42(ByVal int1 As Integer, ByVal int323 As
Integer, ByRef aaaa As Boolean)



End Sub

been a while i wrote in VB.. so please chk syntanx and end of line
etc....But I guess you should get the idea from above...

HTH
VJ
 
G

Guest

You only need to specify the method name after 'AddressOf':
ShowProgress = AddressOf ShowProgress
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: C#/VB to Python converter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top