Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


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

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.

 

 

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