Link to home
Start Free TrialLog in
Avatar of Ranidae
RanidaeFlag for Canada

asked on

VBScript, seperating the output of an echo to columns

Ok.. so I got some help earlier that proved right on, but hadn't forseen the result...
The following script enumerates all the users in the specified OU and echos them to a single message box as a long list.  The problem is if the list is longer than the screen, it just doesn't show the rest of the list.  I need a way for the output (wscript.echo) to be split into columns of 30 lines max or to make the message box scrollable.

Dim UsersInOU(500)
      Set objOU = GetObject("LDAP://" & UserOUPath)
            i = 0
            objOU.Filter = Array("user")
                 For Each objUser In objOU
                      UsersInOU(i) = objUser.Name
                      i = i + 1
                      X = i
                 Next

      Dim strTemp : strTemp = ""

                  For Y = 0 To X
                        strTemp =  strTemp & Y  & " - " & mid(UsersInOu(Y),4,30) & Vbcr
                  Next
Wscript.echo strTemp

Thanks in advance!
ASKER CERTIFIED SOLUTION
Avatar of kapes
kapes

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 Ranidae

ASKER

Way closer... only it only displays the first user name on the first screen then displays 30 on the second third and so on until it only displays X on the last where X is whatever is left and less than 30.
Avatar of Ranidae

ASKER

Hey Kapes, you ROCK!  Thanks for your help... your guidance got me to a point where at least it works!  It may not be pretty but it does what it's supposed to do.

I'll tweak some more later... but for now, here's what it looks like.

Dim UsersInOU(500)
Set objOU = GetObject("LDAP://" & UserOUPath)
i = 1
objOU.Filter = Array("user")
     For Each objUser In objOU
          UsersInOU(i) = objUser.Name
          i = i + 1
          X = i
     Next
Dim strTemp : strTemp = ""

For Y = 1 To 30
strTemp =  strTemp & Y  & " - " & mid(UsersInOu(Y),4,50) & Vbcr
Next

UserID = inputbox("These are the users in the selected group" & Vbcr & Vbcr & strTemp & Vbcr & "What user requires management? (Enter User # or click CANCEL to see next screen)","Users")
            
            If UserID="" Then
                  strTemp = ""
                  For Y = 31 To 60
                  strTemp =  strTemp & Y & " - " & mid(UsersInOu(Y),4,50) & Vbcr
                  Next
                  UserID = inputbox("These are the users in the selected group" & Vbcr & Vbcr & strTemp & Vbcr & "What user requires management? (Enter User # or click CANCEL to see next screen)","Users")
            End if
            If UserID="" Then
                  strTemp = ""
                  For Y = 61 To 90
                  strTemp =  strTemp & Y & " - " & mid(UsersInOu(Y),4,50) & Vbcr
                  Next
                  UserID = inputbox("These are the users in the selected group" & Vbcr & Vbcr & strTemp & Vbcr & "What user requires management? (Enter User # or click CANCEL to see next screen)","Users")
            End if