ASC statement  

Purpose

Replaces one character in a string by using its character code.

Syntax

ASC(stringvar, position&) = CharCode&

Remarks

The ASC statement replaces one character in a string variable.  The position& parameter determines which character is replaced.  The first character is one, the second two, etc.  If position& is negative, ASC counts from the end of the string in reverse.  That is, -1 specifies the last character, -2 specifies the second to last character, etc.

If the stringVar is ANSI, the CharCode must be in the range of 0 to 255.  If Unicode, the CharCode must be in the range of 0 to 65535.

Restrictions

The ASC statement cannot be used to extend the length of a string.  If string is null (zero-length), or position is zero or greater than the length of stringvar, the operation is ignored.

See also

ASC function, CHR$, MID$ statement

Example

A$ = "hello There"
ASC(A$,1) = 72 'replace 1st character with an "H"