Is there a way to make sure the first char in FirstName
and LastName
is uppercase only?
DIM FirstName AS STRING
DIM LastName AS STRING
CLS
INPUT "Enter First Name: ", FirstName
INPUT "Enter Last Name: ", LastName
Is there a way to make sure the first char in FirstName
and LastName
is uppercase only?
DIM FirstName AS STRING
DIM LastName AS STRING
CLS
INPUT "Enter First Name: ", FirstName
INPUT "Enter Last Name: ", LastName
Check this out:
A$ = LEFT$(FirstName$, 1) // get first character
B = ASC(A$) //change it to ascii
IF B >= 65 AND B <= 90 THEN //is it uppercase?
CK$ = "FIRST CHARACTER IS UPPERCASE"
END IF
PRINT CK$
You can use the string functions
LEFT$
andUCASE$
in tandem:If you don't want the program to exit, you could just change it to uppercase yourself by using the
MID$
statement:For more information on string manipulation and conversions and other information, see the QB64 wiki.