A function can use the InStr function to implement the simplicity of the code in a "Heterodoxy" way. The following is a typical example of whether a vowel letter is included in the string:
1, the common method:
If ucase$ (char) = "A" or ucase$ (char) = "E" or ucase$ (char) = "I" or ucase$ (char) = "O" or ucase$ (char) = "U" Then
' It is a vowel
End If
2. A more concise approach:
If InStr ("Aaeeiioouu", Char) Then
' It is a vowel
End If
Similarly, use InStr to check the contents of a variable by using a character that is not in the word as a delimiter. The following example checks to see if Word contains the name of a season: 1. Common method:
If lcase$ (Word) = "Winter" or lcase$ (word) = "Spring" or lcase$ (Word) = _ "Summer" or lcase$ (word) = "Fall" Then
' It is a season ' s name
End If
2. A more concise approach:
If Instr ("; winter;spring;summer;fall;", ";" & Word & ";") Then
' It is a season ' s name
End If
Sometimes, you can even use InStr to replace a select
Case code snippet, but be sure to note the number of characters in the argument. In the following example, the corresponding English name for the conversion number 0 to 9 is Arabic numerals: 1, the normal method:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.