CLS
INPUT "enter any letter"; a$
b$ = UCASE$(a$)
SELECT CASE b$
CASE "a", "e", "i", "o", "u"
END SELECT
IF c$ = b$ THEN
PRINT "Vowel"
ELSE
PRINT "consonant"
END IF
END
如果要与小写字母进行比较,请确保使用LCASE$而不是UCASE$
CLS
INPUT "enter any letter"; a$
b$ = LCASE$(a$)
SELECT CASE b$
CASE "a", "e", "i", "o", "u"
PRINT "Vowel"
CASE ELSE
PRINT "consonant"
END SELECT
您可以使用INSTR
函数来查找输入的字符是否在元音列表中:
CLS
INPUT "enter any letter"; a$
IF INSTR("AEIOUaeiou", a$) THEN
PRINT "Vowel"
ELSE
PRINT "Consonant"
END IF
END
不如使用' UCASE$':
CLS
INPUT "enter any letter"; a$
a$ = UCASE$(a$)
IF INSTR("AEIOU", a$) THEN
PRINT "Vowel"
ELSE
PRINT "Consonant"
END IF
END