Partager via


ASC( ) Function

Returns the ANSI value for the leftmost character in a character expression.

ASC(cExpression)

Parameters

  • cExpression
    Specifies the character expression containing the character whose ANSI value ASC( ) returns. Any characters after the first character in cExpression are ignored by ASC( ).

Return Value

Numeric

Remarks

ASC( ) returns the position of the character in the character table of the current code page. Every character has a unique ANSI value in the range from 0 to 255.

Example

The following example displays the characters A through J and uses ASC( ) to display their corresponding ANSI values.

STORE 'ABCDEFGHIJ' TO gcANSI  && 10 characters
CLEAR
FOR nCOUNT = 1 TO 10
   ? SUBSTR(gcANSI, nCount,1)  && Display a character
   ?? ASC(SUBSTR(gcANSI, nCount)) && Display ANSI value
ENDFOR

See Also

Reference

CHR( ) Function

SET ANSI Command

ANSITOOEM( ) Function

OEMTOANSI( ) Function

Other Resources

Functions

Language Reference (Visual FoxPro)