Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display a drop-down/combo box in VB Script

I'm trying to create a drop-down/combo box in VB Script. As per my understanding we need to create an instance for Internet Explorer and create a drop-down/combo box, something like this:

  set oIE = createObject("InternetExplorer.Application")
  with oIE
    .Navigate "about:blank"
    Do until .ReadyState = 4 : WScript.Sleep 100 : Loop
    set oDoc = .document
    .Visible = true
  end with

  with oDoc
    .open
    .writeln "<html><head><title>ComboBox Example</title></head>"
    .writeln "<body scroll=no><object "
    .writeln "classid=clsid:8BD21D30-EC42-11CE-9E0D-00AA006002F3"
    .writeln "id=ComboBox1 width=400></object><p>"
    .writeln "</body></html>"
    .close
    Do until .ReadyState = "complete" : WScript.Sleep 100 : Loop
    set oComboBox1 = .all.ComboBox1

  end with

  with oComboBox1
    .List = Array("One", "Two", "Three", "Four")
    .AutoWordSelect = true
    .focus
  end with
  oDoc.parentWindow.opener = "Me"

  bClosing = false

  on error resume next
  do until bclosing: wsh.sleep 100 : loop
  oIE.quit

  sub Closing : bClosing = True : end sub

Is it possible to create an dorp-down/combo box without using IE, similar to Message Box or Input Box?

like image 330
Gokul Nath KP Avatar asked Mar 20 '13 05:03

Gokul Nath KP


People also ask

How do you use combo boxes in Visual Basic?

Double click the icon to add a Combo Box to your form. Or click once with the left hand mouse button, and then draw one on the form. A combo box is a way to limit the choices your user will have. When a black down-pointing arrow is clicked, a drop down list of items appears.

How do I create a ComboBox drop-down?

Step 1: Create a combobox using the ComboBox() constructor is provided by the ComboBox class. // Creating ComboBox using ComboBox class ComboBox mybox = new ComboBox(); Step 2: After creating ComboBox, set the DropDownStyle property of the ComboBox provided by the ComboBox class.

How do I populate a ComboBox in VB net?

To add items to a ComboBox, select the ComboBox control and go to the properties window for the properties of this control. Click the ellipses (...) button next to the Items property. This opens the String Collection Editor dialog box, where you can enter the values one at a line.


1 Answers

I'm quite sure many users here will glad to answer on this question, and their reply may hold varied details, but for sure the answer w'd been the same - No. At least not with pure VBScript and without programming your own ActiveX component, which then to instantinate with CreateObject inside your .vbs script.

But if you looking for alternative then may consider HTA as an option for your own custom GUI.

like image 183
Panayot Karabakalov Avatar answered Sep 20 '22 10:09

Panayot Karabakalov