>Hi Cetin
>
>Today, you helped me with a great design to improve my Inlist() function. The result was as follow:
>
>
> ' VFP inlist equivalent
> ' expO1 Item where all the items will be tried to look into
> ' expO2 Param array for a list of items
> Public Function Inlist(ByVal toItem As IComparable, ByVal ParamArray toItems() As IComparable) As Boolean
> Return Array.IndexOf(toItems, toItem) <> -1
> End Function
>
>
>Tonight, I found something strange. I have the following code:
>
>
> If oApp.Inlist(loRow("Type"), 1, 3) Then
> cHtml = cHtml + "313"
> Else
> cHtml = cHtml + "405"
> End If
>
>
>The value of loRow("Type") is 3. I also show it by adding a line just before the condition and it is in fact showing 3. But, it goes in the 405 condition. If I change to this:
>
>
> If oApp.Inlist(3, 1, 3) Then
> cHtml = cHtml + "313"
> Else
> cHtml = cHtml + "405"
> End If
>
>
>It works as expected. Can you see something that could be in effect here to obtain that weird behavior when using a datarow?
>
>If I do this:
>
>
> If oApp.Inlist(CType(loRow("Type"), System.Int32), 1, 3) Then
> cHtml = cHtml + "313"
> Else
> cHtml = cHtml + "405"
> End If
>
>
>It works as expected. But, I don't want to be forced to make that conversion everytime I want to verify for numeric values in Inlist(). The field Type is of Numeric 1 from a VFP table.
Sounds to me like a VFP N(1, 0) is not being interpreted as an integer, maybe some kind of floating point value instead that's not exactly equal to an integer value of 3.
Just in case there might be some effect from your InList() function you could test with a direct comparison:
If loRow("Type") = 3
...
Regards. Al
"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov
Neither a despot, nor a doormat, be
Every app wants to be a database app when it grows up