|
-
March 23rd, 2013, 05:12 PM
#10
Re: Quuikest way to determine if an array element exists in a string
I've got to do a little house cleaning, but this works like a champ - loading one of the other tables, where I do an author look-up, went so fast I thought something was wrong!
Code:
If file = "" Then Return ""
If file.Substring(0, 1) = "*" Then Return file
Dim strTemp As String = CleanInput(file)
Dim strTempAuthor As String = Nothing
Dim strAuthorsOut As String = Nothing
Dim arr1 As String() = file.Split()
Dim names As New ArrayList
Dim arr2(150) As String
Dim i As Integer = 0
Dim j As Integer = 2
While j + i <= arr1.Length
While i + j <= arr1.Length
Array.Copy(arr1, i, arr2, 0, j)
strTempAuthor = Trim(Join(arr2))
If AuthorSearchDict.ContainsKey(strTempAuthor.ToLower) Then names.Add(strTempAuthor)
i += 1
End While
j += 1
i = 0
End While
strAuthorsOut = ""
Dim aname As String
For Each aName In names
strAuthorsOut = strAuthorsOut & aname & "; "
Next
If strAuthorsOut <> Nothing AndAlso strAuthorsOut.Length > 0 Then strAuthorsOut = Microsoft.VisualBasic.Left(strAuthorsOut, Len(strAuthorsOut) - 2)
Return strAuthorsOut
Be more than glad to take any other constructive suggestions you might have!
Last edited by AlJones; March 24th, 2013 at 09:31 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|