Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VBScript, seperating the output of an echo to columns

Posted on 2004-10-29
3
Medium Priority
?
172 Views
Last Modified: 2010-04-14
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!
0
Comment
Question by:Ranidae
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
kapes earned 2000 total points
ID: 12448758
I read your requirement with inputbox..
try this
--------

strtemp = ""
For Y = 0 To X
if (Y Mod 30) = 0 then
      strTemp =  strTemp & Y  & " - " & mid(UsersInOu(Y),4,30)
                UserID = inputbox("These are the users in the selected group" & strTemp & "What user requires management? (Enter User # or click CANCEL to see next screen)","Users")
      If not IsEmpty(userid) Then
            WScript.Echo "user id selected: " & userid
            Exit For
      End If
      strtemp = ""
Else
      strTemp =  strTemp & Y  & " - " & mid(UsersInOu(Y),4,30) & vbcr
end If
Next

0
 
LVL 2

Author Comment

by:Ranidae
ID: 12448937
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.
0
 
LVL 2

Author Comment

by:Ranidae
ID: 12449090
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

0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
Mailbox Corruption is a nightmare every Exchange DBA wishes he never has. Recovering from it can be super-hectic if not entirely futile. And though techniques like the New-MailboxRepairRequest cmdlet have been designed to help with fixing minor corr…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month11 days, 18 hours left to enroll

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question