Re: Array and InputBox Integration ?



On Feb 13, 10:19 am, "Script-Newb" <ClayT...@xxxxxxxxx> wrote:
On Feb 12, 4:51 pm, Jeffery Hicks <"jhicks[at]SAPIEN.com"> wrote:



On 12 Feb 2007 13:19:06 -0800, Script-Newb wrote:

All,
I am having a little trouble getting values of an array to number
themselves in an InputBox for a user to make their choice.
Script Goal = Get a list of all the local user accounts and display
them to a user to choose one of them and store their choice as a
variable for other uses later on.

What I have so far:

Set oNet = CreateObject("Wscript.Network")
strComputer = oNet.ComputerName

ListLocalAccounts

Sub ListLocalAccounts
Set colAccounts = GetObject("WinNT://" & strComputer & "")
colAccounts.Filter = Array("user")
For Each objUser In colAccounts
'This is where I need to make a visible choice list for users to
'Select their old account they were using prior to domain join
WScript.Echo objUser.Name
Next
End Sub

I can get them individually into a inputbox and have a user selct yes
or no but would like it to be a numbered list where they can just pick
a number.

Thanks in advance

Clay

You're limited by the size of the InputBox but I've done things like this:

strMenu=strMenu & "Menu" & VbCrLf
strMenu=strMenu & "1 - apple" & vbCrlf
strMenu=strMenu & "2 - orange" & vbCrlf
strMenu=strMenu & "3 - banana" & vbCrlf
strMenu=strMenu & "Make a selection [1,2,3]"
iOption=InputBox(strMenu,"Menu",1)
WScript.Echo iOption
Select Case CInt(iOption)
Case 1 wscript.echo "you picked apple"
Case 2 wscript.echo "you picked orange"
Case 3 wscript.echo "you picked banana"
Case Else
WScript.Echo "Invalid choice: " & iOption
End Select

--
Jeffery Hicks
SAPIEN Technologies - Scripting, Simplified.www.SAPIEN.com
VBScript & Windows PowerShell Training -www.ScriptingTraining.com/classes.asp
Windows PowerShell? -www.SAPIENPress.com/powershell.asp

blog:http://blog.SAPIEN.com
blog:http://jdhitsolutions.blogspot.com-Hide quoted text -

- Show quoted text -

Thanks for the input but the problem is that i will not know what the
menu options will be or the quantity.
I am pulling all the local accounts off the machine which will vary
from 3-7 accounts. I want to take each one the array finds and make
it a numbered option in an inputbox. I want to use straight vbs/wsh
and not get into an HTA type thing since this inputbox will only be
for on error branch that I hope it will never have to take.

Clay

Come on, be a little creative. Mr. Hicks gave you the basic structure
of what you wanted. Just build the menu string using a variable,
rather than use the literal strings, something like this ...

Sub ListLocalAccounts
Dim aNames(), s, objUser, colAccounts

Set colAccounts = GetObject("WinNT://" & strComputer)

colAccounts.Filter = Array("user")

s = "Enter the number of your selection from below:" & vbNewline
n = 0

For Each objUser In colAccounts
ReDim aNames(n)
aNames(n) = objUser.Name
n = n + 1
s = s & n & ". " & objUser.Name & vbNewline
Next

'This is where you put the choice list for users to
'select the account they were using prior to domain join

Do while n > 0 ' Loops until a 'proper' entry is made
sSelection = InputBox(s, "Make a selection")
if CInt(sSelection) > 0 and CInt(sSelection) <= n Then exit do
msgbox "Your entry was invalid"
Loop

if n > 0 then
' whatever processing is desired goes here
msgbox "You selected: " & aNames(sSelection - 1)
else
msgbox "UNEXPECTED ERROR - No users found."
end if

End Sub

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/

.



Relevant Pages

  • Re: Array and InputBox Integration ?
    ... I am having a little trouble getting values of an array to number ... themselves in an InputBox for a user to make their choice. ... I am pulling all the local accounts off the machine which will vary ... ReDim Preserve aNames ...
    (microsoft.public.scripting.wsh)
  • Re: InputBox methode
    ... I use a french version of Excel 2007, but I think that the version is not in cause ... Your Sub works well, ... Immediately the InputBox shows: second, which I overwrite with BBB, OK. ... So I cannot enter more items than there are in the Default Array. ...
    (microsoft.public.excel.programming)
  • Re: Array and InputBox Integration ?
    ... I am having a little trouble getting values of an array to number ... You're limited by the size of the InputBox but I've done things like this: ... VBScript & Windows PowerShell Training -www.ScriptingTraining.com/classes.asp ... I am pulling all the local accounts off the machine which will vary ...
    (microsoft.public.scripting.wsh)
  • Re: Array and InputBox Integration ?
    ... I am having a little trouble getting values of an array to number ... You're limited by the size of the InputBox but I've done things like this: ... VBScript & Windows PowerShell Training -www.ScriptingTraining.com/classes.asp ... I am pulling all the local accounts off the machine which will vary ...
    (microsoft.public.scripting.vbscript)
  • Re: Finding Login Hours for user accounts in AD
    ... The logonHours attribute is a byte array. ... Accounts with logon hours set will display in the format; ... created by copying other user accounts and retain the same properlys. ...
    (microsoft.public.windows.server.active_directory)

Quantcast