Solved

VBScript, seperating the output of an echo to columns

Posted on 2004-10-29
171 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
Question by:Ranidae
    3 Comments
     
    LVL 6

    Accepted Solution

    by:
    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
    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
    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    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…
    This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    This video discusses moving either the default database or any database to a new volume.

    860 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

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now