David said:
I want to write an IF...THEN statement that checks the value of a control
against a set of values. It would look something like:
If value = In(10,21,34,55,62,104) Then
It would be the equivalent of writing:
If (value = 10) Or (value = 21) Or (value = 34)...
Is there a function like 'In(a,b,c,d)' ???
Thanks,
David
/dmset
This is a function I wrote some time ago to act like the InList function
in FoxPro.
You pass the function your argument and a list of up to 24 items. If
your value
is in the list, it will return true.
If InList(value,10,21,34,55,62,104) Then
Do something
Else
Do something different
Endif
Function INLIST(ByVal testdata As Variant, Optional c1 As Variant,
Optional c2 As Variant, Optional c3 As Variant, Optional c4 As Variant,
Optional c5 As Variant, Optional c6 As Variant, Optional c7 As Variant,
Optional c8 As Variant, Optional c9 As Variant, Optional c10 As Variant,
Optional c11 As Variant, Optional c12 As Variant, Optional c13 As
Variant, Optional c14 As Variant, Optional c15 As Variant, Optional c16
As Variant, Optional c17 As Variant, Optional c18 As Variant, Optional
c19 As Variant, Optional c20 As Variant, Optional c21 As Variant,
Optional c22 As Variant, Optional c23 As Variant, Optional c24 As
Variant) As Boolean
'Test the testdata to see if the value of testdata is in the list from
c1 thru c24
'Return true if found equal in any test. Skips the test is the optional
c1 thru c24 is missing
'-----------------------------------------------------------------------------------------------
INLIST = False
If Not IsMissing(c1) Then
If testdata = c1 Then
INLIST = True
Exit Function
End If
End If
If Not IsMissing(c2) Then
If testdata = c2 Then
INLIST = True
Exit Function
End If
End If
If Not IsMissing(c3) Then
If testdata = c3 Then
INLIST = True
Exit Function
End If
End If
If Not IsMissing(c4) Then
If testdata = c4 Then
INLIST = True
Exit Function
End If
End If
If Not IsMissing(c5) Then
If testdata = c5 Then
INLIST = True
Exit Function
End If
End If
If Not IsMissing(c6) Then
If testdata = c6 Then
INLIST = True
Exit Function
End If
End If
If Not IsMissing(c7) Then
If testdata = c7 Then
INLIST = True
Exit Function
End If
End If
If Not IsMissing(c8) Then
If testdata = c8 Then
INLIST = True
Exit Function
End If
End If
If Not IsMissing(c9) Then
If testdata = c9 Then
INLIST = True
Exit Function
End If
End If
If Not IsMissing(c10) Then
If testdata = c10 Then
INLIST = True
Exit Function
End If
End If
If Not IsMissing(c11) Then
If testdata = c11 Then
INLIST = True
Exit Function
End If
End If
If Not IsMissing(c12) Then
If testdata = c12 Then
INLIST = True
Exit Function
End If
End If
If Not IsMissing(c13) Then
If testdata = c13 Then
INLIST = True
Exit Function
End If
End If
If Not IsMissing(c14) Then
If testdata = c14 Then
INLIST = True
Exit Function
End If
End If
If Not IsMissing(c15) Then
If testdata = c15 Then
INLIST = True
Exit Function
End If
End If
If Not IsMissing(c16) Then
If testdata = c16 Then
INLIST = True
Exit Function
End If
End If
If Not IsMissing(c17) Then
If testdata = c17 Then
INLIST = True
Exit Function
End If
End If
If Not IsMissing(c18) Then
If testdata = c18 Then
INLIST = True
Exit Function
End If
End If
If Not IsMissing(c19) Then
If testdata = c19 Then
INLIST = True
Exit Function
End If
End If
If Not IsMissing(c20) Then
If testdata = c20 Then
INLIST = True
Exit Function
End If
End If
If Not IsMissing(c21) Then
If testdata = c21 Then
INLIST = True
Exit Function
End If
End If
If Not IsMissing(c22) Then
If testdata = c22 Then
INLIST = True
Exit Function
End If
End If
If Not IsMissing(c23) Then
If testdata = c23 Then
INLIST = True
Exit Function
End If
End If
If Not IsMissing(c24) Then
If testdata = c24 Then
INLIST = True
Exit Function
End If
End If
End Function
HTH
Ron