wsyeager Posted March 2, 2006 Posted March 2, 2006 (edited) I'm 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: 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? Edited February 19, 2007 by PlausiblyDamp Quote Thanks, Bill Yeager (MCP, BCIP) Microsoft Certified Professional Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer YeagerTech Consulting, Inc.
*Experts* Nerseus Posted March 2, 2006 *Experts* Posted March 2, 2006 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: Private Shared Function ProductGT11(ByVal p As String) As Boolean I just removed the parens from the parameter "p". -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Administrators PlausiblyDamp Posted March 2, 2006 Administrators Posted March 2, 2006 Not 100% sure and haven't got VS handy to test it but I think the ProductGT11 method should look like Private Shared Function ProductGT11(ByVal p As String) As Boolean Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
wsyeager Posted March 3, 2006 Author Posted March 3, 2006 Thanks, that was it! Quote Thanks, Bill Yeager (MCP, BCIP) Microsoft Certified Professional Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer YeagerTech Consulting, Inc.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.