Revision [13937]

This is an old revision of KeyPgAsc made by JeffMarshall on 2008-11-30 07:37:21.

 

ASC


Returns the corresponding ASCII or Unicode integer representation of a character

Syntax:
Usage:
result = Asc( str [, position ] )

Parameters:
str
The source string.
position
The position in the string of a character.

Return Value:
The ASCII or Unicode integer representation of the character at position in str.

Description:
If str is a KeyPgString String or a KeyPgZstring ZString, an CptAscii ASCII code value is returned.
If str is a KeyPgWstring WString, a CptAscii Unicode code value is returned.

The function returns zero (0) if the string is a zero length string, position is less than one (1), or position is greater than the number of characters in str.

KeyPgChr Chr performs the opposite function for ASCII strings, while KeyPgWchr WChr is the opposite for Unicode strings, returning a string containing the character represented by the code passed as an argument.

Examples:
Print "the ascii code of 'a' is:"; Asc("a")
Print "the ascii code of 'b' is:"; Asc("abc", 2)
will produce the output:

the ascii code of 'a' is: 97
the ascii code of 'b' is: 98


Unicode example (Note to documentation editors: don't put inside %%(qbasic) markers or the Russian text will disappear!)

dim a as wstring * 11
a = "Привет, мир"
print "the Unicode of the second char of " & a & " is: " & asc(a)
 
will produce the output:
the Unicode of the second char of Привет, мир is: 1088
 

Platform Differences:
Differences from QB:
See also:
Back to String Functions
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode