Asc Function

See Also1B6IPK              Example2IES9RR>Low

Returns a numeric value that is the ANSI5221FB code for the first character in a string expression1330R89.

Syntax

Asc(stringexpression)

Remarks

If the stringexpression argument is a zero-length String or a Null1DDW7C0 Variant8PHEAW3 (VarType7A68ZTZ 1), a run-timeCYRM35 error will occur.


See Also

ANSI Character Set108ABF

Chr, Chr$ FunctionLANCHR


Asc Function Example

The example uses the Asc function to return the numeric equivalent of a range of characters.  To try this example, paste the code into the Declarations section of a form.  Then press F5 and click the form.

 

Sub Form_Click ()

   Dim I, Msg                      ' Declare variables.

   For I = Asc("A") To Asc("Z")    ' From A through Z.

      Msg = Msg & Chr(I)           ' Create a string.

   Next I

   MsgBox Msg                      ' Display results.

End Sub