Link to home
Start Free TrialLog in
Avatar of smsstech
smsstechFlag for Canada

asked on

Sort contents of text file with headers alphabetically using vbs

Hi all,

I need to sort, using vb script, the contents of a text file that looks like this:

[WEBN]
Wam Es= 1
AIG Esk=1
Aviv RJF=1
[TABB]
Sch Ins=1
CMH Cap=1
AIG Esk=1
Stikem Ell=1

to have the information under the users name alphabetical like this:

[WEBN]
AIG Esk=1
Aviv RJF=1
Wam Es= 1
[TABB]
AIG Esk=1
CMH Cap=1
Sch Ins=1
Stikem Ell=1

As you can see, the only items to be sorted are those between the closing ] of a users name to the opening [ of another users name, etc.  Please note that I do not need the users sorted at all, just the data below their section.  In my example, [WEBN] can continue to come before [TABB].

I need this in vb script.  Any help would be appreciated.  Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Shift-3
Shift-3
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of smsstech

ASKER

Shift-3, thank you very much.  That worked like a charm.  I was originally getting a ubound error with my array and was starting to second guess myself, hence the support call as my issue was becoming urgent.  Perfect coding my man.  Cheers.