String manipulation

wsyeager

Well-known member
Joined
Apr 10, 2003
Messages
140
Location
Weston, FL
Im using the new TextFieldParser class and want to find out how to use the "Find" method of the Array object after I parse multiple fields of a line into a string array.
Here is the code:
Code:
Private Sub ParseData2()

        Dim fields As String()
        Dim parser As New TextFieldParser("c:\epp\test.txt")

        Try
            parser.SetDelimiters(";")
            parser.TrimWhiteSpace = True
            While Not parser.EndOfData
                 Read in the fields for the current line
                fields = parser.ReadFields()
                Dim str As String = Array.Find(fields, AddressOf ProductGT11)
            End While
        Catch ex As Exception
            Throw ex
        End Try

    End Sub

    Private Shared Function ProductGT11(ByVal p As String()) As Boolean
       code here will do the find
    End Function

The "AddressOf ProductGT11" inside the ParseData2 sub is giving me a compile time error:
Method Private Shared Function ProductGT11(p() as string) as Boolean does not have the same signature as delegate Delegate Function Predicate(Of T)(obj as String) As Boolean

How can I correct his?
 
Last edited by a moderator:
The function ProductGT11 should take a single parameter that matches the type of the array - in your case a string. So the definition should be:
Code:
Private Shared Function ProductGT11(ByVal p As String) As Boolean

I just removed the parens from the parameter "p".

-ner
 
Not 100% sure and havent got VS handy to test it but I think the ProductGT11 method should look like
Code:
Private Shared Function ProductGT11(ByVal p As String) As Boolean
 
Back
Top