>It looks weird at first but numeric 1 (System.Decimal) is not equal to integer 1. Silly computers:)
>If you had 1.0,3.0 in your list it would do. I tried to write a generic version of InList in VB < vbg >
>
>
> Private Function InList(ByVal searchFor As Object, ByVal ParamArray paramList() As Object) As Boolean
> Try
> Dim local As Object = Convert.ChangeType(searchFor, paramList(0).GetType())
> Return (Array.IndexOf(paramList, local) <> -1)
> Catch ex As Exception
> MessageBox.Show(ex.Message)
> End Try
> Return False
> End Function
>
>
>This is not "generic" as I wrote yesterday (I mean it is not utilizing System.Collections.Generic with strong type support).
>Second what I don't really like is that it uses ParamArray with object type. Objects might be from different types and no check for that. ie: Consider these calls:
>
>1) If InList(loRow("Type"), 1,3,DateTime.Now,"2.00") Then
>
>2) If InList(loRow("Type"), "1.00",3,DateTime.Now,"2.00") Then
>
>3) If InList(loRow("Type"), DateTime.Now, 1, 3) Then
>
>and let loRow("Type") was decimal 1,2,3 or 5.
>1) 1 and 3 would be in list.
>2) 1 and 2 would be in list
>3) InvalidCastException
>
>IOW first parameter in ParamArray is assumed to be the same for all array elements. It still covers VFP Inlist IMHO (with one exception - it lets you compare a decimal to a string as in case# 2).
>Anyway I couldn't do something more elegant in VB:)
Thanks for the additional information
I think I will keep it as is. To accomodate the situation of yesterday, I will simply convert to the proper type before verification.