Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Multiline input box

Posted on 2007-11-29
15
Medium Priority
?
6,355 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 2000 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

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.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

730 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