Export (0) Print
Expand All
Expand Minimize

Converting VBScript's Asc Function


Windows PowerShell


Definition: Returns the ANSI character code corresponding to the first letter in a string.

Asc

It’s surprising how often scripters need to convert a character value (such as the letter A) to its ASCII equivalent (65). In Windows PowerShell you can determine the ASCII value of a character by using this crazy-looking line of code (which takes the character value of the letter A and then converts the result to a byte value):



$a = [byte][char] "A"

When you run this command and then echo back the value of $a you should get the following:



65


Return to the VBScript to Windows PowerShell home page

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft