473,320 Members | 2,158 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,320 software developers and data experts.

How to pass a collection of comboboxes to a Sub?

Hello everyone,
I would like too generate a number of comboboxes at runtime and then pass them to a Sub, like this:
Expand|Select|Wrap|Line Numbers
  1. For i = 0 to maxnumber
  2.   Dim cbo As New ComboBox()
  3.   cbo.Name = "cbo" & i
  4.   etc...
  5. Next
  6. etc...
  7. Myroutine("collection of comboboxes")
  8.  
  9. Sub Myroutine(ByVal "collection of comboboxes")
  10.   ...do something with the comboboxes...
  11. End Sub
  12.  
What is the correct syntax to use to pass the comboboxes collection to the Sub?

Thank you.
Feb 6 '10 #1

✓ answered by tlhintoq

Dim ComboList As List(Of Combobox) = Nothing
Try setting your ComboList equal to a new List(Of Combobox) instead of setting it to nothing (null)

4 1370
tlhintoq
3,525 Expert 2GB
When you are making the comboboxes add them to a List<combobox> or an array combobox[] then send that array
Feb 6 '10 #2
Tlhintoq, tThank you very much for you input, I have tried:

Dim ComboList As List(Of Combobox) = Nothing
For i etc...
Dim cbo As New ComboBox()
ComboList.Add(cbo)
Next

but I get an error "Object reference not set to an instance of an object".
There is still something I am missing...
Feb 6 '10 #3
tlhintoq
3,525 Expert 2GB
Dim ComboList As List(Of Combobox) = Nothing
Try setting your ComboList equal to a new List(Of Combobox) instead of setting it to nothing (null)
Feb 6 '10 #4
Thanks a lot... that made it!
Feb 6 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Wandy Tang | last post by:
Dear All, How to pass a collection from a VB Component to an ASP page? I have no clue the syntax of all. Many Thanks. Regards, Wandy Tang
1
by: Andrés Giraldo | last post by:
Hi! I'm trying to pass trough all the objects of a form but I have some text inputs in a DIV and I have many DIVs like this on my form. I'm doing something like: for (i = 0; i <...
5
by: Mark Dicken | last post by:
Hi All, I am trying to Pass A Collection To A FUNCTION ??? (Access 2000) I have a Class called BO (for Business Objects) Within BO I have a Function called ShowCollection Public Sub...
1
by: Mark Dicken | last post by:
Hi All I have found the following Microsoft Technet 'Q' Article :- Q210368 -ACC2000: How to Pass an Array as an Argument to a Procedure (I've also copied and pasted the whole contents into...
0
by: johnson_cy | last post by:
I am using Access 2000. My main form has a record source of a table (employeeTbl with key of . It is filtering the record results. My subform and mainform have the link child/link master set...
4
by: deko | last post by:
This is a basic program flow question. I'm trying to refractor an AC2000 app and split sections of code into separate modules. But there are a number of collections I create in one big module -...
1
by: Josema | last post by:
Hi to all, i have a class (of type collectionbase) that creates a collection of objects for instance persons. For other hand i have a Datagrid whose Datasource its the collection wich i...
4
by: Alexander Kolev | last post by:
I have a huge struct with many members.I don't want to copy this struct to the stack, that's why i pass it by reference to a function. But also i want the function to be unable to modify it....
1
by: Craig G | last post by:
for months we have been dabling round looking at various 3rd party comboboxes that allow the user to type text into the combobox as a search mechanism what we've found is that the likes of...
2
by: Matt | last post by:
Hi all, me again! :) I've now got an issue with combo boxes. Basically, I have a number of items that I want a user to pick from a single list. It's basically along the lines of: Fruit 1: ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...

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.