Solved

Multiline input box

Posted on 2007-11-29
15
5,670 Views
Last Modified: 2010-04-21
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
Comment
Question by:Steynsk
  • 5
  • 4
  • 3
  • +1
15 Comments
 
LVL 17

Expert Comment

by:Shanmuga Sundaram
ID: 20375210
Better try using text box, make its property to multiline
0
 
LVL 17

Expert Comment

by:Shanmuga Sundaram
ID: 20375211
multiline property to True if you are using visual basic
0
 
LVL 17

Expert Comment

by:Shanmuga Sundaram
ID: 20375231
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 18

Expert Comment

by:Crash2100
ID: 20375750
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
 
LVL 1

Author Comment

by:Steynsk
ID: 20376714
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
 
LVL 18

Expert Comment

by:Crash2100
ID: 20377734
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
 
LVL 18

Expert Comment

by:Crash2100
ID: 20377747
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
 
LVL 1

Author Comment

by:Steynsk
ID: 20380869
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
 
LVL 65

Expert Comment

by:RobSampson
ID: 20538524
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
 
LVL 65

Expert Comment

by:RobSampson
ID: 20538536
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
 
LVL 1

Author Comment

by:Steynsk
ID: 20539983
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
 
LVL 65

Expert Comment

by:RobSampson
ID: 20539999
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
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 20540024
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
 
LVL 1

Author Closing Comment

by:Steynsk
ID: 31411706
Hello Rob,

Thats it. It works perfectly
Thanks a lot,

Steynsk
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 20545781
No problem Steynsk, glad to help.

Rob.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

773 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