HTA, Removing Selected Items from a Combo Box - vbscript

So i have an HTA that populates a combo box based on SCCM client installs that are available and have not yet been run. Everything works fine except for the combo box whats supposed to happen is whatever program is selected runs, and is then installed and removed from the Combo box. However no matter what program i select the first Item is removed every time, I've tried a few different variations but nothing seems to work, any help is appreciated.
Dim i
strSelectedValues = ""
' Check all the Options of the ListBox
For i = 0 To (objComboBox.Options.Length - 1)
' Check if the Current Option is Selected
If (objComboBox.Options(i).Selected) Then
' Collect only the Selected Values
strSelectedValues = strSelectedValues & objComboBox.Options(i).Value
End If
Next
'Remove selected program to install from the Combo box list
ComboBox1.Remove(SelectedItem)

According to this authority, .remove needs the number/index of the option to remove. SelectedItem seems to be undefined/empty/for practical purposes: zero in your code; then it seems reasonable that the first option vanishes. So try
ComboBox1.Remove ComboBox1.selectedIndex
(perhaps guarded by a check that there is a selected option - or should it go into the loop?)

Related

Blocking code in custom message box in VB6

In my vb6 project, I created my own msgbox using a form, due to difficulties in changing
the font/language of in-built msgbox. A search with google gave the idea of own msg-
box rather than trying msgbox of VB. Now the problem is : - when the user exits the
program, 3 options are given: to close, to restart and to cancel exit. The user need not
again go through the process of giving password etc in restart option. If I give cancel =
true in the QueryUnload event, then 2nd option does not work, 3rd option works. If
cancel = true is not given, 2nd option works, but 3rd option does not. It appears that
the main form does not get unloaded if cancel = true. Unless & until the main form
unloads, the program will not work with the fresh data to be given by the user in the
initial Form. Since the code after "msgbox.show" depends on options, it is not possible
to write that code in the same sub, not even in the same form code. Is there any way
to stop the subsequent code after "msgbox.show" and continue the same after getting
option? (like in the in-built msgbox of VB.) I am not an expert in VB, so please correct
if I made some mistake; also help with advice/suggestions.
EDIT:- [Extended explanation]
The 3 forms in my project:
Initial form for password, data etc. This is input Form for user.
Main Form. This Form shows the results after process of input.
frmMsgBox. This is a custom msgbox created using a form.
Main Form code portion. Code for closing the program:
Private Sub Form_QueryUnload(Cancel as.......)
cancel = True
frmMsgBox.Label1.caption = Do you wish to 1.Exit 2.Restart
3.Cancel the exit?
frmMsgBox.Show
End sub
(The above msgbox is almost like an in-built msgbox in VB with
vbYesNoCancel buttons) The message is in regional language,
which was the main reason forced me to use my own msgbox.
After MsgBox appears, the user selects one of the above options
using 3 commandButtons placed in that Form. The code after
clicking these buttons is written in the code portion of frmMsgBox:
Command1_Click 'This is for Exit from the Program.
All Forms.unload, All forms set to nothing, end.
Command2_click 'This is for restarting the Program.
Unload Main Form, set to nothing
Load Initial Form
Initial Fom.show
frmMsgBox.Hide
Command3_Click 'This is for cancelling the exit request.
Main Form.Show
frmMsgBox.Hide
With the above code, I have no problem with options 1 & 3,
i.e; to exit from the program or to start. The frmMsgBox hides,
the initial form shows - these are OK, but the main form does
not unload nor it is removed from memory. Because of this,
whatever new data is given by the user in the initial form now
is not being processed, the main form is struck with the old results.
If cancel = true is removed from the code above, Options 1 & 2
are OK, but option 3 does not work. Then the Main Form loses
all its results (all labels, texts etc in that Form turn blank.)

If statement in QF-test

I am learning QF-test and want to do a simple if statement. If I make a change on this one page it enabled an "Apply" button that I want to click if it becomes enabled.
When I check if the button is enabled this is what appears
Check boolean: enabled (true) [buttonApply=>($client)]
So I want to say something like
if 'buttonApply.enabled'=="true"
Mouse Click [buttonApply=>($client)]
but that doesn't seem to work
Well I emailed QF-test support and got this answer
Set the variable in the field 'Variable for Result'. Let's say 'CompPresence'
When you run the script , the variable 'CompPresence' will be filled with the value 'true' if the button "Apply" is enabled.
You can use the If loop like If '$(CompPresence)'==”true”

Comparing Data In Text Boxes in Visual Studio 2013

So I mostly use Microsoft Excel for a lot of my work and the most "Programming" I do is writing basic logical functions in excel.
I am setting up a windows form in Visual Studio 2013 and I want to the end user to be able to be able to confirm that the data they input into TEXTBOX1 matches what is in TEXTBOX2.
So normally in excel I can just write =IF(C2=D2,"Yes","No")
So basically I want to be able to input data in the carton field and then in the label field and if it matches I want it to say yes in the text box at the bottom.
I tried writing
If CartonBarcode = LabelBarcode Then
PartCheck = "Yes"
Else : PartCheck = "No"
End If
but that hasn't worked - I am very new to VB so please be gentle.
Eventually I also want to be able to append the scanned data (If the two text boxes match) into an excel spreadsheet.
Thanks in advance for all your help =)
Thanks for your help Mark - that makes a lot of sense.
I added this IF Statement to the PartCheck text box but it doesn't seem to display Yes or No regardless of what I put in.
It now throws two errors (look to be the same error on each line.)
Value of type 'String' cannot be converted to 'System.Windows.Forms.TextBox'
Any further help you can provide would be fantastic
Screenshot of errors
I then changed PartCheck = "Yes" to PartCheck.Text = "Yes" and it runs but then nothing displays in the PartCheck Text Box
In WinForms, TextBox and other GUI components (e.g. Label, Button) are objects, with properties and methods to interact with them. If you want to compare the text that has been entered into two TextBox objects, you will need to compare their Text properties. e.g.
Update
Updated code below based on your updated question. You are correct that you need PartCheck.Text = "Yes" to set it correctly. Your current issue is when you are performing the check. You are handling the TextChanged event for your PartCheck TextBox, but your logic should really be triggered when either the CartonBarcode or LabelBarcode text is changed. You can either have TextChanged handlers for both of those TextBox controls, and call a common subroutine to perform the check, or have a common TextChanged handler, as shown below:
Private Sub Barcode_TextChanged(sender As Object, e As EventArgs) _
Handles CartonBarcode.TextChanged, LabelBarcode.TextChanged
If CartonBarcode.Text = LabelBarcode.Text Then
PartCheck.Text = "Yes"
Else
PartCheck.Text = "No"
End If
End Sub

Google Apps Script listbox to dropdown box

I'm building a UI in Google Sites using Apps Script and I am able to create a listbox. According to the documentation if you change the setVisibleItemCount to 1 it will become a dropdown box.
I have tried both 1 and 0.
Neither seems to make it a drop-down box. Using Firefox 13.0.1 to view. Have also tried Safari.
Anyone had any luck with this?
Code looks like this:
var vPanel = container.createVerticalPanel();
//List box
var lb = container.createListBox(true).setId('listbox').setName('listbox');
// add items to ListBox
for(var i=0;i<LIST_OF_PROJECTS.length;i++){
lb.addItem(LIST_OF_PROJECTS[i]);
}
vPanel.add(lb);
lb.setVisibleItemCount(1); //supposed to make it a drop-down but doesn't
lb.setSelectedIndex(0);
This is all inside a Google Site and the page that is being displayed is a Apps Script Page. Perhaps you are NOT using Google Sites? Above code gives me a single line but no drop down arrow.
Could you post your relevant code please ?, It's working for me on firefox (slightly differently), chrome & safari. (see screen cap when I click the selector, SetVisibleItemCount is 1)
thx
EDIT : One important point : to get the list acting as a dropdown list you have to choose 'disable multiple selection', in other words : createListBox(false) or no parameter... but not 'true' as it is in your code !! (now we know why it doesn't work in your case ;-)
With this parameter set to false , it works as expected in standalone webapp, embedded on site and linked to spreadsheet without any difference.
Don't call:
setVisibleItemCount
at all.

JqGrid multi select list always has first option selected in edit mode with IE7/8

The grid (v4.3.1) selects the correct values in the drop down when going into edit mode.
However, there seem to be an issue with IE 7 and IE 8, which automatically select the first item, along with the other values that also should get selected.
Have anyone stumbled upon this with IE7/8?
While studying the source for jqgrid I also saw a commented line that actually would fix this issue. It was commented in this changeset and fixed another issue, as Oleg commented. Haven't yet found out what that issue was though.
I examined the described problem and can confirm, that it's a bug in jqGrid. So +1 for you in any way.
The line
//if(i===0) { this.selected = ""; }
was commented after the fix which you referenced was made based on the problem with single selected selects. See the post. So I can suggest two ways to fix the problem:
1) replace the above comment to the following lines
// fix IE8/IE7 problem with selecting of the first item on multiple=true
if (i === 0 && elem.multiple) { this.selected = false; }
2) add instead of that after the $("option",elem).each(function(i){...}) the lines
// fix IE8/IE7 problem with selecting of the first item on multiple=true
var $first = $("option:first",elem);
if($.inArray($.trim($first.text()),ovm) < 0 && $.inArray($.trim($first.val()),ovm) < 0 ) {
$first[0].selected = false;
}
I am not sure which bug fixing is the most safe.
The demo can be used to reproduce the bug. One can use IE9, start Developer Tools with F12, choose IE8 as the "Browser mode" and choose "IE Standards" as the "Document Mode". After all one can select item "SM000237" in the grid and verify that "Accounting free" item are selected together with "Bank Fees" instead of selecting only the "Bank Fees".
The first and the second demos both fixes the bug and use the described above fixes.

Resources