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

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6639
  • Last Modified:

Multiline input box

Hello Expert,

I am looking for some code that makes a mulitiline inputbox (lets say 10 lines) to catch some lines and put them into a array. The functionality is planned to get multiple AD usernames seprated by ";". The usernames should be stored into an array.

The script should have the .vbs extention!

Thanks
0
Steynsk
Asked:
Steynsk
  • 5
  • 4
  • 3
  • +1
1 Solution
 
Shanmuga SundaramCommented:
Better try using text box, make its property to multiline
0
 
Shanmuga SundaramCommented:
multiline property to True if you are using visual basic
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Crash2100Commented:
Like that article mentioned, you can do this quite easily with the split command.  Something like this:

Dim x() As String
x = Split(Text1.Text, ";" & vbCrLf)
MsgBox x(1)
0
 
SteynskAuthor Commented:
I don't understand. You guys tell me to use textbox and the multiline property. But I don't need the the code in webpage but in a .vbs script (wscript). Or does this not mater?

Can someone please send a sample?

Thanks
0
 
Crash2100Commented:
I missed the part about using VBS.  Try putting your input in a text file, and use something like this:

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("test.txt",1)

Do Until objTextFile.AtEndOfStream
strComputer = strComputer & chr(13) & objTextFile.Readline
Loop

Wscript.Echo "File's whole contents: " & strComputer

'Split the contents
dim a
a=Split(strComputer, ";" & chr(13))
Wscript.Echo "First line: " & a(0)
Wscript.Echo "Second line: " & a(1)
0
 
Crash2100Commented:
Take a look at this website, it documents a lot of this stuff:

http://www.w3schools.com/vbscript/

VBScript Functions
http://www.w3schools.com/vbscript/vbscript_ref_functions.asp
0
 
SteynskAuthor Commented:
No sorry no result. So maybe I have to accept it is not possible. So I move to plan B:

I encountered a problem like this before with making a selection box with a .VBS script. And made little step to HTML to get things done. I've found the script and rebuild it a little. But the only thing I can't figure out is how to catch the input and separate it and store the thunks in to an array. So maybe you guy can help me out. This is the Idea:

sNames = TextBox("Please provide usernames seperated by a ';' ")
Function TextBox(sTitle)
  Dim oIE, s, item
  set oIE = CreateObject("InternetExplorer.Application")
  With oIE
    .FullScreen = True
    .ToolBar   = False : .RegisterAsDropTarget = False
    .StatusBar = False : .Navigate("about:blank")
    Do Until .ReadyState = 4 : WScript.Sleep 100 : Loop
    .width= 400 : .height=200
    With .document
      with .parentWindow.screen
        oIE.left = (.availWidth  - oIE.width ) \ 2
        oIE.top  = (.availheight - oIE.height) \ 2
      End With
      s = "<html><head><title>" & sTitle _
        & "</title></head><script language=vbs>bWait=true<" & "/script>" _
        & "<body bgColor=Silver><center>" _
            & "<b>" & sTitle & "<b><p>" _
        & "<textarea id=entries cols=40 rows=4></textarea><<p>" _
        & "<button id=but0 onclick='bWait=false'>OK</button>" _
        & "</center></body></html>"
      .open
      .Write(s)
      .close
      Do until .ReadyState ="complete" : Wscript.Sleep 50 : Loop
      With .body
        .scroll="no"
        .style.borderStyle = "outset"
        .style.borderWidth = "3px"
      End With
      .all.entries.focus
      oIE.Visible = True
      CreateObject("Wscript.Shell").AppActivate sTitle
      On Error Resume Next
      Do While .ParentWindow.bWait
        WScript.Sleep 100
        if oIE.Visible Then SelectBox = "Aborted"
        if Err.Number <> 0 Then Exit Function
      Loop
      On Error Goto 0
      With .ParentWindow.entries
        SelectBox = .options(.selectedIndex).text
      End With
    End With
    .Visible = False
  End With
End Function

The line:

SelectBox = .options(.selectedIndex).text

Should be replaced for something else

Thanks,

Steynsk

0
 
RobSampsonCommented:
Hi there, sorry to jump in so late, but if what you want to do is prompt a user to enter usernames separated by a semi-colon, can the user put that all on one line, like with this code:

strInput = InputBox("Please provide usernames seperated by a ';')
arrArray = Split(strInput, ";")
For Each strUsername In arrArray
   MsgBox strUsername
Next

Regards,

Rob.
0
 
RobSampsonCommented:
Ooops, forgot a closing quote before the first closing bracket....should be:

strInput = InputBox("Please provide usernames seperated by a ';'")
arrArray = Split(strInput, ";")
For Each strUsername In arrArray
   MsgBox strUsername
Next

Regards,

Rob.
0
 
SteynskAuthor Commented:
Hi Rob,

Thanks for the input but I realy need a "multiline" input box. I use the script in the way you discribe it. But I realy need multiline functionality.

Thanks anyway,

Steynsk
0
 
RobSampsonCommented:
Can I ask then, if you want a user to put each username on a separate line, do you really need to separate it by a semi-colon?  Couldn't you just Split by the vbCrLf character?

Rob.
0
 
RobSampsonCommented:
Try replacing
SelectBox = .options(.selectedIndex).text

with
MsgBox oIE.document.all.Entries.Value

and that should show you the value, so then use
arrNames = Split(oIE.document.all.Entries.Value, ";")

Regards,

Rob.
0
 
SteynskAuthor Commented:
Hello Rob,

Thats it. It works perfectly
Thanks a lot,

Steynsk
0
 
RobSampsonCommented:
No problem Steynsk, glad to help.

Rob.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now