Export (0) Print
Expand All
Expand Minimize

Converting VBScript's Len Function


Windows PowerShell


Definition: Returns the number of characters in a string or the number of bytes required to store a variable.

Len

The “length” of a string is simply the number of characters contained in that string. In Windows PowerShell you can determine the length of a string by retrieving the value of the aptly-named Length property. In this example we stored the 26 letters of the English alphabet in a variable named $a, then assign the length of that string to the variable $b:



$a = "abcdefghijklmnopqrstuvwxyz"
$b = $a.length

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



26


Return to the VBScript to Windows PowerShell home page

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