• Post author:
  • Post category:VB
  • Reading time:2 mins read
VB.NET Tutorials

In VB, the Asc functions return the numeric code of a character.

Advertisement

Syntax

Asc (strExpression)
AscB (strExpression)
AscW (strExpression)

Where the strExpression argument is a string for which you want to return the numeric code of the first character.

Example

Dim intAnsi as Integer
intAnsi = Asc("Hello")

Output

The above example places the value 72 (the ANSI code for the character H) in the variable intAnsi.

Advertisement

Asc

The Asc function returns the numeric ANSI value of the first character in the supplied string. The range of returns is 0 to 255 on the non-DBCS systems and -32768 to 32767 on DBCS systems.

AscB

The AscB function in VB is used with byte strings. Instead of returning the character code for the first character, AscB returns the first byte.

AscW

The AscW function returns the Unicode character code, except on platforms where Unicode is not supported; in those cases, the behavior of AscW is identical to the Asc function.

Advertisement
Related:  VB Chr Function

Vinish Kapoor

An Oracle Apex Consultant, Oracle ACE, and founder of foxinfotech.in and orclqa.com a question and answer forum for developers.