Sorting an array is a common scripting task. The task is so common, in fact, that JScript (Microsoft's version of JavaScript) includes a sort method that sorts an array. VBScript, however, lacks the native capability to sort an array. I've written a Windows script component, VBSort.wsc, to address this limitation. Listing 1 shows VBSort.wsc. The Penton.VBSort object, implemented in the VBSort.wsc file, provides a set of three properties and a method that lets you quickly sort an array in VBScript.
Registering the Component
As with all script components, you must register VBSort.wsc on your computer before you use it in your scripts. To perform the registration, right-click VBSort .wsc in Windows Explorer and choose Register. (Conversely, to unregister the component, right-click VBSort.wsc and choose Unregister.) To register the component from a command prompt, use the following command:
regsvr32 /i:"path\VBSort.wsc"
%SystemRoot%\system32 scrobj.dll
where path is the directory in which theVBSort.wsc file resides. . . .
Why become a VIP member?
 |
VIP-only online access |
 |
VIP CD delivered twice a year: offline access to the entire Windows IT Pro article library |
 |
Monthly issue of your choice of Windows IT Pro or SQL Server Magazine |