anandkasotia
Member
- Joined
- Aug 30, 2010
- Messages
- 6
- Programming Experience
- 1-3
Here's the code I have but I'm getting syntax issues:
Public Class frmABC
Public Delegate Sub DlgReadAndPopulate(ByRef ABC1 As AutoSQLServerVehicleCriteria, ByRef XYZ1 As SortedList(Of Integer, AutoExcelRaterPremiums))
Private Sub DoTheFollowing()
Private Sub ReadAndPopulate(ByRef ABC As AutoSQLServerVehicleCriteria, ByRef XYZ As SortedList(Of Integer, AutoExcelRaterPremiums))
End Class
I'm just looking to call ReadAndPopulate method for each item in aList. I know I can do it the traditional "For each a in aList...Next" way but wanted to learn how to do it with delegates.
Public Class frmABC
Public Delegate Sub DlgReadAndPopulate(ByRef ABC1 As AutoSQLServerVehicleCriteria, ByRef XYZ1 As SortedList(Of Integer, AutoExcelRaterPremiums))
Private Sub DoTheFollowing()
Dim aList As List(Of AutoSQLServerVehicleCriteria) = New List(Of AutoSQLServerVehicleCriteria)
Dim MyGreeting As DlgReadAndPopulate
MyGreeting = AddressOf ReadAndPopulate
aList.ForEach(AddressOf MyGreeting)This is where it has a squiggly line under MyGreeting and says: 'AddressOf' Opperand must be the name of a method (without parenthesis). Not sure what I'm doing wrong here.
End SubDim MyGreeting As DlgReadAndPopulate
MyGreeting = AddressOf ReadAndPopulate
aList.ForEach(AddressOf MyGreeting)This is where it has a squiggly line under MyGreeting and says: 'AddressOf' Opperand must be the name of a method (without parenthesis). Not sure what I'm doing wrong here.
Private Sub ReadAndPopulate(ByRef ABC As AutoSQLServerVehicleCriteria, ByRef XYZ As SortedList(Of Integer, AutoExcelRaterPremiums))
Some code
End Sub
End Class
I'm just looking to call ReadAndPopulate method for each item in aList. I know I can do it the traditional "For each a in aList...Next" way but wanted to learn how to do it with delegates.