473,587 Members | 2,320 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 26339
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
7918
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8206
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
8340
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
7967
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
8220
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
5713
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
3840
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3875
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2353
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.