I have a listbox. How do I select the 3rd item in the listbox out of many items? - forms

I have a form with 10 listboxes on it. I also have a command button. How do I make it so that if I press the command button it will select the 3rd item of a listbox of my choosing?

You may do so by converting your 10 listboxes into a control array. If I remember correctly, you do so by specifying the same Name property and a unique, non-negative Index property for each one of the ListBox instances in your form.
Assuming you named all of your list boxes as ListBoxArr and set up the Index property so that the first listbox is 0, the second one is 1, etc. then you can write something like this
' Access the 6th list box and select the third item
' Remember, Index values are zero-based, so 0 is first item...
ListBoxArr(5).ListIndex = 2

Related

Click on checkboxes based on text in another column and status of checkbox

I have a table on a page with 50 check boxes and some columns, and I need to click on the ones that has a specific text on the last column. So I used this command:
//table[#id='edit-entities']/tbody/tr[td[6][contains(text(), 'New')]]/td/div/input
It worked, Selenium clicks on the first one. Now I need to know how can I make Selenium to click in the other ones.
I tried:
//table[#id='edit-entities']/tbody/tr[td[6][contains(text(), 'New')]]/td/div/input[2]
I put the index [2] in the front of the input to test if it would click on the second check box matching this condition, but it says it did not find the element.
Figured out ... the index must be the row index and not the checkbox index:
//table[#id='edit-entities']/tbody/tr[td[6][contains(text(), 'New')]][4]/td/div/input

How to get `length` of Matlab GUI popup menu strings

I want to get how many strings exist in the popup menu, how can this be done? This code that I have written does not seem to work.
length(get(handles.popupMenu,'Value'))
Value is the index of the currently selected item in the menu so it will only ever be a scalar. You instead want to check the length of the String property which contains a cell array of strings (one for each item).
nOptions = numel(get(handles.popupMenu, 'String'));

Excel Form VBA Combobox reset

This should be easy but I can't seem to find anything to solve. I have a Form in Excel using VBA. The Excel sheet has four columns populated with data and the Form displays those fields.
The user then selects a value in a combobox, uses a command button to submit the responses and the values from the combobox are written to the Excel sheet.
The user then uses a command button to advance one row down in the spreadsheet and load the four values from a new row. This all works great.
The issue I am trying to solve is that the combobox remains selected to the value in the prior selection. I'd like to reset the combobox so nothing is selected and the user has to make a selection again for the next row.
Below is the code I am using to load the combobox and to set a variable for what the user selected. Can't seem to get the combobox back to it's default state after the user has submitted the form.
Private Sub cbDesAccWanted_Change()
Select Case cbDesAccWanted.Text
Case "Yes"
desacc = "Yes"
Case "No"
desacc = "No"
End Select
cbDesAccWanted.Text = desacc
End Sub
Private Sub cbDesAccWanted_DropButtonClick()
cbDesAccWanted.List = Array("Yes", "No")
End Sub
There are two ways to reset the combobox. Take your pick:
1
cbDesAccWanted.Value = Null
2
cbDesAccWanted.ListIndex = -1
the line
cbDesAccWanted.Text = desacc
is totally unnecessary.
Using cbDesAccWanted_DropButtonClick is not the right place to populate the list of values. This list should be set up when the form is first shown to the user.
(unelss the values it shows chnages in which case change it when the row changes or something, not when the user clicks on it)
So when theuser clicks the down arrow to move to thenext record include the following line
Me.cbDesAccWanted.text = Me.cbDesAccWanted.List(1)
Note (1) access teh 2nd item in the list which is No.
So this reset it to the default value of No.
Ok.

MATLAB GUI pop-up menu list get disappear when I set a default string?

can somebody please tell me why my pop-up menu list get disappear when I set a string which actually belongs to one of the item in the list? I want this string to be appear as default when GUI gets open, however, want other items to be in the pop-up menu.
For example, pop-up list contains:
Set_1
Set_2
Set_3
Set_4 etc..
And, in the function OpeningFcn, I am settting:
set(handles.popupmenu1, 'String', 'Set_1');
This makes 'Set_1' to appear when I open GUI. However, it makes other items (Set_2, Set_3 etc) disappear from the GUI. Thanks.
The String property of a popupmenu uicontrol sets the entire text that is displayed in the menu.
To select a particular option, set the Value property to the index of the item to be selected. In this case, since Set_1 is the first item, set the Value property to 1.

how to implement a combo box matching the last in the autocomplete

For the auto-complete functionality, it will automatically matching the prefix of the items.
And focus the first of the filtered items. But i would like to let the combo-box focus on the last items of the filtered items.
For instance, if the dataset are "ABA,ABB,ACC", if i input AB, the ABA and ABB will be filtered, and the focus will be on the ABA(above ABB), now what i want is focus on ABB(below ABA).
I checked that combo-box does have AutoCompleteMode, but none of them seems can do this
You can specify a custom auto complete source that is different from the combo-box items list. This allows you to specify entries that are sorted in reverse order and to keep the right order for the combo-box items at the same time
cb.AutoCompleteSource = AutoCompleteSource.CustomSource;
var strings = new AutoCompleteStringCollection();
strings.AddRange(arrayWithItemsInReverseOrder);
cb.AutoCompleteCustomSource = strings;