Hi,
I am programming scripts to easily process a lot of measurement data
from work. In order to be able to group certain data into summary output
files, I would like to give the user the chance to select grouping
criteria via multiple choice boxes, such as:

Group by:
[ ] Date
[ ] Measurement Target
[ ] Process
.....

Is there any way to bring up such a multiple choice box in VB Script and
react to the responses via select?

Alternatively, is there any way to bring up a MsgBox where I can
actually customize the reply buttons? So far, I only saw options like
"Yes", "No" and "Cancel".

Are you aware of any publicly posted subfunction that does either one of
these?

Thanks,
Martin

Re: multiple choice boxes by mayayana

mayayana
Fri Mar 14 08:50:00 CDT 2008


In straight VBS there are only basic message boxes.
They're modeled on the system message boxes and
are not customizable. The easiest option, if you're familiar
with HTML, is to use an HTA with a number of radio
button INPUT tags all sharing the same ID.

If you don't need to deal with IE7 you can create
fairly convincing custom msgboxes using IE:
www.jsware.net/jsware/scripts.php3#msgb

In IE7 the ability to size the window while also
removing the IE "chrome" has been removed, so
it doesn't work as well. You can still make a msgbox,
but it's clunky-looking.

> I am programming scripts to easily process a lot of measurement data
> from work. In order to be able to group certain data into summary output
> files, I would like to give the user the chance to select grouping
> criteria via multiple choice boxes, such as:
>
> Group by:
> [ ] Date
> [ ] Measurement Target
> [ ] Process
> .....
>
> Is there any way to bring up such a multiple choice box in VB Script and
> react to the responses via select?
>
> Alternatively, is there any way to bring up a MsgBox where I can
> actually customize the reply buttons? So far, I only saw options like
> "Yes", "No" and "Cancel".
>
> Are you aware of any publicly posted subfunction that does either one of
> these?
>
> Thanks,
> Martin



Re: multiple choice boxes by Paul

Paul
Fri Mar 14 11:52:46 CDT 2008

A standalone VBScript can create an IE window as explained by
mayayana.

You could also put your VBScript into a .hta file, and run it as an
Html application, which avoids the IE7 problems, I think.

Htas have the advantage of allowing multiple scripting languages to be
used, so if you can find Perl, Rex, Python, Ruby, or a number of other
language code snippets or routines that do what you need done, they
can be integrated fairly easily. Htas give you all the standard web
page controls.

Microsoft has a freely downloadable HTA-HelpOMatic.hta which
demonstrates how to use a number of Html controls. And it is a great
help at creating the code for and testing parts of the hta you build.
http://www.microsoft.com/downloads/results.aspx?pocId=&freetext=hta&DisplayLang=en

-Paul Randall

<mayaXXyana1a@mindXXspring.com>
"Martin Glodde" <glodde@sas.upenn.edu> wrote in message
news:63vbloF29onteU1@mid.individual.net...
> Hi,
> I am programming scripts to easily process a lot of measurement data
> from work. In order to be able to group certain data into summary
> output files, I would like to give the user the chance to select
> grouping criteria via multiple choice boxes, such as:
>
> Group by:
> [ ] Date
> [ ] Measurement Target
> [ ] Process
> .....
>
> Is there any way to bring up such a multiple choice box in VB Script
> and react to the responses via select?
>
> Alternatively, is there any way to bring up a MsgBox where I can
> actually customize the reply buttons? So far, I only saw options
> like "Yes", "No" and "Cancel".
>
> Are you aware of any publicly posted subfunction that does either
> one of these?
>
> Thanks,
> Martin



Re: multiple choice boxes by mr_unreliable

mr_unreliable
Sat Mar 15 21:50:48 CDT 2008

This is a multi-part message in MIME format.
--------------070508040105000300010906
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Martin Glodde wrote:
> Alternatively, is there any way to bring up a MsgBox where I can
> actually customize the reply buttons? So far, I only saw options like
> "Yes", "No" and "Cancel".
>

Martin, if you are courageous enough, or foolhardy enough to
be willing to use a 3rd-party control, then there are several
utilities which will allow you to show any graphic (GUI) that
you can think of. For example:

kixForms (written by: Shawn Tassie of CGI Canada):
http://www.kixforms.org/assets/index.htm

wshDialog (written by: Peter J.C. van der Klugt):
http://home.hccnet.nl/p.vd.klugt/,

These 3re-party controls must be downloaded, installed and
registered, but then you can GUI-it-up as far as your
imagination can carry you.

There is a demo attached, using KixForms to show a dialog
with some option buttons (a.k.a. radio buttons)...

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)


--------------070508040105000300010906
Content-Type: text/plain;
name="wshSimpleKixFormsDemo.vbs.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="wshSimpleKixFormsDemo.vbs.txt"

' wshSimpleKixFormsDemo Script, jw 15Mar08
'
' Author: mr_unreliable
' Usage: Use at you own risk, tested on win98se...
'
Dim oKixSystem : Set oKixSystem = CreateObject("Kixtart.System")
' Set Up the Top-Level Container (called "the Form Object")
Dim oForm : Set oForm = oKixSystem.Form()
Dim oBtn, oLbl, oRB1, oRB2, oRB3 ' as object(s)
Dim sUserSelection ' as string
Dim bCloseEvent ' as boolean
' --- end of global variables --------------------

' ================================================
' === MAIN LINE SCRIPT LOGIC HERE ================
' ================================================

Call Create_Dialog() ' using kixforms

bCloseEvent = False

Do
WScript.Sleep 100

' --- discussion of event processing ----------
' o.k., can't say how this works exactly. The Documentation says:
' "DoEvents returns a string representing the next event in the queue".
' Apparently that string referred to is the string stored in the event
' property. For example: say a click event is detected, then the
' DoEvents method will return the string stored in the onClick property.
' Then that string (retrieved by DoEvents) gets executed here...
'
' As to the DoEvents "wait" parameter, according to the documentation:
' false means process an event if one is detected, but otherwise DON'T WAIT for an event.
' true means wait (i.e., don't return until there is some event to report).
' But here, it seems to work JUST THE OPPOSITE from what the doc says.
' Ain't this fun...
' --- end of discussion ----------------------
Execute(oForm.DoEvents(True)) '
Loop Until (bCloseEvent)


' o.k., the demo is finished, now exit gracefully...
oRB1.Visible = False ' hide the controls
oRB2.Visible = False
oRB3.Visible = False
oBtn.Visible = False
oLbl.Text = "the demo is finished"
WScript.Sleep 1000
oLbl.Text = "this dlg will close in 2ses"
WScript.Sleep 2000

oForm.Visible = False
Set oForm = nothing
Set oKixSystem = nothing
WScript.Quit


' ================================================
' === SUBROUTINES FOLLOW =========================
' ================================================

Sub oForm_Click()
MsgBox("form click detected(!)")
End Sub

Sub oBtn_Click()
MsgBox("your selection was: " & sUserSelection & vbCrLf & vbCrLf _
& " the script will now close... ")
bCloseEvent = True
End Sub


Sub Create_Dialog()

With oForm
.Text = " How would you like to ""group"" your stuff... " ' the form caption
.MinimizeBox = "False"
.MaximizeBox = "False"
.Resizable = 0
.BackColor = "Azure" ' &HD0D0D0 ' Lt Gray
.Width = 300
.Height = 160
.FontName = "Verdana"
.FontBold = True
.FontSize = 10
.onClick = "oForm_Click()"

Set oLbl = .Controls.Add("Label")
With oLbl
.Left = 20 : .Top = 10 : .Width = 270 : .Height = 15
.Text = "Group Criteria... "
End With ' olbl

' add a "radiobutton" (aka option button) to the form...
Set oRB1 = .Controls.Add("RadioButton")
With oRB1
.Left = 20 : .Top = 30 : .Width = 180 : .Height = 20
.BackColor = oForm.BackColor
.FontSize = 9
.FontBold = False
.Text = "Date"
.Checked = True ' select as default
sUserSelection = oRB1.Text ' default result
.onClick = "sUserSelection = oRB1.Text" ' (onEvent, do this)
End With ' oRB1

Set oRB2 = .Controls.Add("RadioButton") ' another radio button
With oRB2
.Left = 20 : .Top = 50 : .Width = 180 : .Height = 20
.BackColor = oForm.BackColor
.FontSize = oRB1.FontSize : .FontBold = oRB1.FontBold
.Text = "Measurement"
.onClick = "sUserSelection = oRB2.Text"
End With ' oRB2

Set oRB3 = .Controls.Add("RadioButton") ' another radio button
With oRB3
.Left = 20 : .Top = 70 : .Width = 180 : .Height = 20
.BackColor = oForm.BackColor
.FontSize = oRB1.FontSize : .FontBold = oRB1.FontBold
.Text = "Process"
.onClick = "sUserSelection = oRB3.Text"
End With ' oRB3

' add a button to the form...
Set oBtn = .Controls.Add("Button")
With oBtn
.Left = 60 : .Top = 100 : .Width = 190 : .Height = 20
' .BackColor = &HFF ' this doesn't seem to work
.FontSize = 9
.FontBold = False
.Text = "Submit Grouping Selection"
.onClick = "oBtn_Click()" ' click event handler
End With ' obtn



.Show ' show the form
End With ' oform

End Sub

--------------070508040105000300010906--

using wshDialog as a gui by mr_unreliable

mr_unreliable
Sun Mar 16 16:34:31 CDT 2008

This is a multi-part message in MIME format.
--------------050300070107020107080204
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

mr_unreliable wrote:
> There is a demo attached, using KixForms to show a dialog
> with some option buttons (a.k.a. radio buttons)...
>
There is ANOTHER demo attached here, showing how to
use the "wshDialog" utility for the same thing.

cheers, jw

--------------050300070107020107080204
Content-Type: text/plain;
name="wshDialogDemo_wOptBtns.vbs.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="wshDialogDemo_wOptBtns.vbs.txt"

' simple wshDialog Demo, jw 16Mar08
' wshDialog comes with some sample code, this was one of them,
' but was also "enhanced" somewhat (sorry P.J.C. vd Klugt).
Option Explicit

Dim oDlg, oFrm, oBtn ' as object(s)
Dim sOpt ' as string

Const vbModal = 1

' create the WshDialog.Kit object...
Set oDlg = Wscript.CreateObject("WshDialog.Kit", "oDlg_")

Call CreateDialog()

oFrm.Show vbModal ' show the form (modal)

' in this case, modal means the script stops until the user closes the form,
' (or clicks the button).

' N.B. even though the form has been closed, one can "reach back" into the form,
' and get out "user input", such as text entered or options selected,
' so long as the form has not been "unloaded"...
sOpt = oFrm.GetOptionButton("Frame1") ' get control selected
MsgBox "You selected: " & oFrm.Ctl(sOpt).Caption, vbInformation, _
" wshDialogDemo Results "

Set oFrm = nothing
Set oDlg = nothing
WScript.Quit


' ================================================
' === SUBROUTINES FOLLOW =========================
' ================================================

Sub CreateDialog()
' --- discussion ---------------------------------
' While wshDialog is a nice utility, there is one annoying thing about it,
' at least as far as I am concerned -- that is, "twips" is used as the
' measurement for the various controls. This may be something that is
' "natural" for a vb coder, but most system api's are pixel-oriented,
' and so am I. And so, I am going to be "working" with pixels, and
' then converting pixels-to-twips in order to comply with Herr PJC vdKlugt's
' wishes. (You may think this is more trouble than it's worth)...
' use the utility functions up front, then dismiss oVBU...
' Dim oVBU : Set oVBU = WScript.CreateObject("wshNonModalDialog.ucVBU", "")
' Dim vbScreen : Set vbScreen = oVBU.vbScreen
' Dim scTPPX : vbScreen.TwipsPerPixelX
' Dim scTPPY : vbScreen.TwipsPerPixelY
' Set vbScreen = nothing
' MsgBox("scTPPX/scTPPY: " & CStr(scTPPX) & "/" & CStr(scTPPY))
' --- end of discussion --------------------------
Dim scTPPX : scTPPX = 15 ' vbScreen.TwipsPerPixelX
Dim scTPPY : scTPPY = 15
Dim wdFrm : wdFrm = 300 * scTPPX
Dim htFrm : htFrm = 180 * scTPPY
Dim wdFrame : wdFrame = 250 * scTPPX
Dim htFrame : htFrame = 100 * scTPPY
Dim leftFrame : leftFrame = 10 * scTPPX
Dim topFrame : topFrame = 10 * scTPPY
Dim wdOB : wdOB = 150 * scTPPX
Dim htOB : htOB = 20 * scTPPY
Dim leftOB : leftOB = 15 * scTPPX
Dim topOB : topOB = 20 * scTPPY
Dim leftBtn : leftBtn = 65 * scTPPY
Dim topBtn : topBtn = 120 * scTPPY
Dim wdBtn : wdBtn = 160 * scTPPX
Dim htBtn : htBtn = 25 * scTPPY

' form constructor...
Set oFrm = oDlg.NewForm("Sample")

With oFrm

.Width = wdFrm : .Height = htFrm

' adjust form properties...
.CaptionEx = " How would you like to ""group"" your stuff... "
.MinBox = False : .CloseBox = True ' False ' close with the button
.Icon = oDlg.LoadPic("mru.ico") ' GetIcon("mru.ico")
.Taskbar = True

' adding controls. Add button first, so it gets the initial focus...
Set oBtn = .NewButton("btnSubmit", leftBtn,topBtn, wdBtn,htBtn, "Submit Criteria")
oBtn.Default = True

' add frame with option buttons...
.NewFrame "Frame1", leftFrame,topFrame, wdFrame,htFrame, " Group Criteria "
.NewOptionButton "OptBtn1", leftOB,topOB, wdOB,htOB, "Date", True, "Frame1" ' set as default
topOB = topOB + 25 * scTPPY
.NewOptionButton "OptBtn2", leftOB,topOB, wdOB,htOB, "Measurement", False, "Frame1"
topOB = topOB + 25 * scTPPY
.NewOptionButton "OptBtn3", leftOB,topOB, wdOB,htOB, "Process", False, "Frame1"

End With ' oFrm

End Sub

--------------050300070107020107080204
Content-Type: image/x-icon;
name="Mru.ico"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="Mru.ico"

AAABAAEAICAEAAAAAADoAgAAFgAAACgAAAAgAAAAQAAAAAEABAAAAAAAAAIAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAACAAACA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