ASC function

Purpose:

ASC returns the code point value of a character.

Syntax:

RetVal = ASC(Character AS STRING, _
               [Index AS INTEGER])

Return Value:

  • Data type: INTEGER
    RetVal Code point value of Character.

Parameters:

  • Data type: STRING
    Character String literal containing any printable character or a string variable containing a character in the Windows Code Page code point range 0 to 255. If the string contains more than one character only the value of the first character in the string will be returned.
  • Data type: INTEGER
    Index [OPTIONAL] is an integer which specifies the location of the character for which the code point value is to be returned. The Index value of the first character is 0, the second character 1 and so on.

Example 1:

This example will return the code point value for "A", the first character in the string "ABC".

DIM RetVal%

RetVal% = ASC("ABC")

PRINT RetVal%

Result:

 65

Example 2:

This example will return the code point value for "C", the third character in the string "ABC".

DIM RetVal%

RetVal% = ASC("ABC", 2)

PRINT RetVal%

Result:

 67

Remarks:

CHR$ is a function complementary to ASC. CHR$ returns the literal character when given an Windows Code Page code point integer argument.

BCX Console Sample Programs using ASC function.