This command will determine the length of the string variable A$ in characters. The result of this command is a number, which will be the number of alphanumeric characters that are in the string variable.


This command only works with string variables.  It does not work with numeric variables.


Replace the A$ with whatever string variable you wish to know the length of.


Try this small GWBASIC program.



10 CLS

20 A$=”Hello world”

30 L=LEN(A$)

40 PRINT A$; “Contains “;L;” characters.”

50 END


Type RUN to run the program which should result in the following being shown on the screen.


Hello world contains 11 characters.


Note that it counted even the blank space between the words as a character.