ASC function

Purpose: ASC returns the ASCII value of a character.


 Syntax:

 Value% = ASC(Character$, [Index%])

 Parameters:

  • Value% Returned integer containing ASCII code.
  • Character$ String literal containing any printable character or a string variable containing a character in the ASCII code 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.
  • Index% [OPTIONAL] is an integer which specifies the location of the character for which the ASCII value is to be returned. The Index% value of the first character is 0, the second character 1 and so on.

Example 1 :


 Value% = ASC("ABC")

Result:

Value% will equal 65

Example 2 :


 Value% = ASC("ABC",2)

Result:

Value% will equal 67

Remarks: CHR$ is a function complementary to ASC. CHR$ returns the literal character when given an ASCII integer argument.

BCX Console Sample Programs using ASC function.

S33.bas S75.bas