LEN( )
This article is a stub. You can help improve Basic Programming Wiki Complete by expanding it.

LEN - return the number of characters (length) of a string

Syntax

numChar = LEN$( str )

  • numChar - returned character count
  • str - string to be counted

Description

LEN$() counts the number of characters (letters, numbers, spaces, punctuation, etc) in a string. It then returns the number.

Examples

Example of Use

After the below example code is run, the value of numChar will be 8.

numChar = LEN$("12345678")

Checking User Input

If you know that the player's input must be above or below a certain number of characters, you can (in some occasions) use LEN$() to check if the player has entered a valid response.

DIM A AS STRING
INPUT "Type red or blue", A
IF LEN$(A) < 3 OR LEN$(A) > 4 THEN PRINT "You didn't type red or blue."

Related Pages

page tags: function length string
page_revision: 2, last_edited: 1207774602|%e %b %Y, %H:%M %Z (%O ago)