473,405 Members | 2,262 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Number of items in combobox

Hi.

I have a combobox with a value list of 4 items. My code needs to know
the number of items in that combobox.

How can I use VBA to get the number of items in a combobox?

TIA

--
Georges
Nov 12 '05 #1
4 26294
Check out the properties and methods of the combo box control...
Specifically, the 'ListCount' property...
"Georges Heinesch" <vo**@void.com> wrote in message
news:40********@news.vo.lu...
Hi.

I have a combobox with a value list of 4 items. My code needs to know
the number of items in that combobox.

How can I use VBA to get the number of items in a combobox?

TIA

--
Georges

Nov 12 '05 #2
This works. Thanks a lot.

Is it also possible to ask which of the items is presently selected.
This would be the counterpart of teh method ItemData(), which sets the item.

TIA

Georges

--

Ruskin wrote:
Check out the properties and methods of the combo box control...
Specifically, the 'ListCount' property...
"Georges Heinesch" <vo**@void.com> wrote in message
news:40********@news.vo.lu...
Hi.

I have a combobox with a value list of 4 items. My code needs to know
the number of items in that combobox.

How can I use VBA to get the number of items in a combobox?

TIA

--
Georges

Nov 12 '05 #3
..ListCount
- Count of records in combo box

..ListIndex
- Index of selected record, where it starts at 0. If this is '-1' then no
record has been selected

..Text
- Text of selected record

..ItemData(.ListIndex)
- Basically the same as .Text, but you can supply the list number... NOTE:
the index number must be between 0 and ListCount minus one...

Eg:

If myCombo.ListIndex = -1 Then
MsgBox "Please select a value"
Else
MsgBox "Using Item Data: " & myCombo.ItemData(myCombo.ListIndex)
MsgBox "Same as Text: " & myCombo.Text
End If
"Georges Heinesch" <vo**@void.com> wrote in message
news:40********@news.vo.lu...
This works. Thanks a lot.

Is it also possible to ask which of the items is presently selected.
This would be the counterpart of teh method ItemData(), which sets the item.
TIA

Georges

--

Ruskin wrote:
Check out the properties and methods of the combo box control...
Specifically, the 'ListCount' property...
"Georges Heinesch" <vo**@void.com> wrote in message
news:40********@news.vo.lu...
Hi.

I have a combobox with a value list of 4 items. My code needs to know
the number of items in that combobox.

How can I use VBA to get the number of items in a combobox?

TIA

--
Georges


Nov 12 '05 #4
This all works perfectly now.
Thanks a lot!

Georges

--

Ruskin wrote:
..ListCount
- Count of records in combo box

..ListIndex
- Index of selected record, where it starts at 0. If this is '-1' then no
record has been selected

..Text
- Text of selected record

..ItemData(.ListIndex)
- Basically the same as .Text, but you can supply the list number... NOTE:
the index number must be between 0 and ListCount minus one...

Eg:

If myCombo.ListIndex = -1 Then
MsgBox "Please select a value"
Else
MsgBox "Using Item Data: " & myCombo.ItemData(myCombo.ListIndex)
MsgBox "Same as Text: " & myCombo.Text
End If

Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Georges Heinesch | last post by:
Hi. I have a combobox with a value list of 4 items. My code needs to know the number of items in that combobox. How can I use VBA to get the number of items in a combobox? TIA --
2
by: Rey | last post by:
Howdy all. This may have been covered previously but I've had no success in retrieving it... Where may I find what the limitations are of the various controls, i.e. number of records/items that...
19
by: hao | last post by:
Hi, all, Is it possible to list a huge number of items in ComboBox and make it quick? Like 50,000 items? My customer use MS Access before and in Access, he can use ComboBox from...
0
by: bcreighton | last post by:
I have created a bound subform on an unbound masterform linked together with a common field (A store's identification number) using an unbound combobox on the masterform and an invisible field on...
5
by: Rich | last post by:
Hello, I have a search application to search data in tables in a database (3 sql server tables). I populate 2 comboboxes with with data from each table. One combobox will contain unique...
8
by: manojsingh | last post by:
hi, How can i count number of combobox in my html page. thanx Manoj
4
by: hhak | last post by:
Hi all, Im pretty new to C#, im trying to assign a combobox selected value to a int variable. int number; combobox has items added (1,2,3,4,...9) when i select a number from the combobox i...
1
by: JAnn81 | last post by:
I have a combo box created using xaml. I bind the item source to a xml document. <Items> <Item> <Name>David</Name> <Age>20</Age> </Item> <Item> <Name>Marcus</Name> <Age>25</Age>
1
by: sanndeb | last post by:
I have a combobox like <ComboBox Height="23" HorizontalAlignment="Left" Margin="88,13,0,0" Name="cmbYears" VerticalAlignment="Top" Width="112" SelectionChanged="cmbYears_SelectionChanged"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.