Solved

Multiline input box

Posted on 2007-11-29
15
5,463 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
Comment Utility
Better try using text box, make its property to multiline
0
 
LVL 17

Expert Comment

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

Expert Comment

by:Shanmuga Sundaram
Comment Utility
0
 
LVL 18

Expert Comment

by:Crash2100
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 1

Author Comment

by:Steynsk
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Hello Rob,

Thats it. It works perfectly
Thanks a lot,

Steynsk
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
No problem Steynsk, glad to help.

Rob.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

744 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

17 Experts available now in Live!

Get 1:1 Help Now