Hi Parke
Use this it will give you proper result if all value in lower case
index =myAl.IndexOf(LCase("Quick"))

this will not solve your exact problem (case insensitive).but I think it
will be help full for you.

-- 
Thanks  & Regards
Sujit :)

On Thu, May 31, 2012 at 8:07 PM, Parke Kuntz <[email protected]> wrote:

> Found a work around for doing a case insensitive search for an
> unsorted arrayList
> (
> http://bytes.com/topic/visual-basic-net/answers/388832-case-insensitive-arraylist-indexof-search
> )
>
> Also included is a way to perform a case insensitive search on a
> sorted arrayList
>
>
> Dim myAl, i, s
> Set myAL = DotNetFactory.CreateInstance("System.Collections.ArrayList")
>
> ' used in a binary search on a sorted arrayList
> Dim caseInsen
> Set caseInsen=
> dotNetFactory.CreateInstance("System.Collections.CaseInsensitiveComparer")
>
> myAL.Add ("The" )
> myAL.Add ("quick" )
> myAL.Add ("brown" )
> myAL.Add ("fOx" )
> myAL.Add ("jumps" )
> myAL.Add ("over" )
> myAL.Add ("the" )
> myAL.Add ("lazy")
> myAL.Add ("dog" )
> 'myAL.Add ("fox" )
>
> s = ""
> For i = 0 to myAL.count - 1
>        s = s & " " & myAL.item(CInt(i))
> Next
>
> print s
>
> ' can use IndexOf to locate index without doing a sort
> ' this is case sensitive
> If myAL.contains("fox") Then
>        print "found fox using contains and index = " & myAL.IndexOf("fox")
> Else
>        print "did not find the word fox"
> End If
>
> ' change everything to LCase to make equivalent to case insenstive
> ' advantage is if the same word occurs more than once, each occurance
> is displayed
> Dim indexOf
> For i = 0 to myAL.count - 1
>         If LCase(CStr(myAL.item(CInt(i)))) = LCase("fox") Then
>                indexOf = i
>                print "Found LCase fox and index = " & indexOf
>        End If
> Next
>
>
> Dim index
> ' only the first occurance of the search is displayed
> myAL.Sort(caseInsen.Default)
> index = myAL.BinarySearch("fox",caseInsen.Default)
> print "After sorting, fox found at index = " & index
>
> On 5/30/12, Parke <[email protected]> wrote:
> > I can run the following:
> >
> > Dim myAl, i, s
> > Set myAL =
> > DotNetFactory.CreateInstance("System.Collections.ArrayList")
> > myAL.Add  ("The" )
> > myAL.Add ("quick" )
> > myAL.Add ("brown" )
> > myAL.Add ("fox" )
> > myAL.Add ("jumps" )
> > myAL.Add ("over" )
> > myAL.Add ("the" )
> > myAL.Add ("lazy")
> > myAL.Add ("dog" )
> >
> > s = ""
> > For i = 0 to myAL.count - 1
> >       s = s & " " & myAL.item(CInt(i))
> > '     msgbox myAL.item(CInt(i))
> > Next
> > msgbox s
> > ' can use IndexOf to locate index without doing a sort
> > If myAL.contains("fox") Then
> >       print "found fox using contains and index = " & myAL.IndexOf("fox")
> > End If
> >
> > But if "fox" is changed to "foX", foX is not found.  How do I call for
> > a CaseInsensitive comparison?  This might also be useful in the
> > dotNetFactory dictionary or hashTables.  I am slowly working my way
> > through the methods found at
> > http://msdn.microsoft.com/en-us/library/system.array_methods
> > .
> >
> > Thanks for any and all help,
> >
> >
> > Parke
> >
> > --
> > You received this message because you are subscribed to the Google
> > "QTP - HP Quick Test Professional - Automated Software Testing"
> > group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group at
> > http://groups.google.com/group/MercuryQTP?hl=en
> >
>
>
> --
> Parke
> Cell: 770-842-0121
>
> --
> You received this message because you are subscribed to the Google
> "QTP - HP Quick Test Professional - Automated Software Testing"
> group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/MercuryQTP?hl=en
>

-- 
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en

Reply via email to