RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: VB7
Expertise: beginner
Apr 27, 2002



Building the Right Environment to Support AI, Machine Learning and Deep Learning

CompareValue - Check whether a value is in a list of values

' Compares a numeric or string value with a list of other values.
' Returns the 1-based index of the matching value, or zero if the
' value doesn't appear in the list.
' String comparisons are case-sensitive.
' This function can conveniently replace a Select Case or a list
' of ORed comparison, e.g. you can replace the following line
'        If s = "one" Or s = "Two" Or s = "Three" Then
' with the more concise
'        If CompareValue(s, "One", "Two", "Three") Then

Function CompareValue(ByVal value As Object, ByVal ParamArray valueList() As _
    Object) As Integer
    Return Array.IndexOf(valueList, value) + 1
End Function
Francesco Balena
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date