473,586 Members | 2,682 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 26338
Check out the properties and methods of the combo box control...
Specifically, the 'ListCount' property...
"Georges Heinesch" <vo**@void.co m> 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.co m> 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(.Lis tIndex)
- 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.ListInd ex = -1 Then
MsgBox "Please select a value"
Else
MsgBox "Using Item Data: " & myCombo.ItemDat a(myCombo.ListI ndex)
MsgBox "Same as Text: " & myCombo.Text
End If
"Georges Heinesch" <vo**@void.co m> 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.co m> 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(.Lis tIndex)
- 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.ListInd ex = -1 Then
MsgBox "Please select a value"
Else
MsgBox "Using Item Data: " & myCombo.ItemDat a(myCombo.ListI ndex)
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
502
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
3482
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 can be displayed in a dropdown combobox. In Paradox, this is 2500 items. If, for instance, a customer table has more than the limitation, I'm...
19
1567
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 datagrid(datasheet view in Access) to select item. The speed is good in Access with Autocomplete. Now in our new project, he still wish we can make it possible in...
0
346
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 the subquery, which filters for a particular store. The subform is in continuous mode. So, what you see when you select a store is a list of all...
5
5897
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 CompanyID's. The second combobox will contain unique memberID's. Each of the tables that I have to search contain a CompanyID and a memberID field, and...
8
18884
by: manojsingh | last post by:
hi, How can i count number of combobox in my html page. thanx Manoj
4
27907
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 want to assign this number to my integer variable. thanks in advance.
1
14682
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
24494
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" Canvas.Left="13" Canvas.Top="0"> <ComboBox.Items> <ComboBoxItem Tag="2010" Content="2010" /> <ComboBoxItem Tag="2011" Content="2011" />...
0
7839
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8202
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7959
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8216
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5710
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.