We help IT Professionals succeed at work.

Would like an auto adjusting InputBox

LawrenceBYork
on
Basically I have a script with one line like:
   variable = InputBox("some prompt", "some title")
which works fine for sinle line / single item entry.  However, what I'd like to have happen is that the box is capable of multiple line / item inputs as well.  So if there is only one item to process the action on, just enter the item name and click "ok".  If there are multiple items to process action on, simply enter them one line at time by pressing return after each (inputbox auomatically expands so you can see the list, or is scrollable -- then "ok" to finish.  Is this possible?  If so, how?
Comment
Watch Question

SILVER EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
Hi,

In short, no this is not possible with the standard input box, unless you ask the user how many items they want to enter, like so:
'==================
intItems = Int(InputBox("How many items do you want to enter?","Amount of Items","1"))
ReDim arrItems(intItems - 1)
For intItem = 0 To UBound(arrItems)
      arrItems(intItem) = InputBox("Please enter item number " & intItem + 1 & " of " & UBound(arrItems) + 1 & ":","Item Number " & intItem + 1 & " of " & UBound(arrItems) + 1)
Next
MsgBox Join(arrItems, VbCrLf)
'==================

The only way to have a multi-line text box is to build a HTA.
http://www.microsoft.com/technet/scriptcenter/hubs/htas.mspx

Regards,

Rob.

Author

Commented:
Unfortunately that's what I feared.  Ok, thanx!

Explore More ContentExplore courses, solutions, and other research materials related to this topic.