[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Combining With Statements

Posted on 2013-05-20
4
Medium Priority
?
221 Views
Last Modified: 2013-05-21
How can I combine the following into one With statement in VB6?

With Cbo1
.Additem "One"
.Additem "Two"
.Additem "Three"
End With

With Cbo2
.Additem "One"
.Additem "Two"
.Additem "Three"
End With
0
Comment
Question by:al4629740
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 4

Expert Comment

by:frankd
ID: 39181979
Cbo1.Additem "One"
Cbo1.Additem "Two"
Cbo1.Additem "Three"
Cbo2.Additem "One"
Cbo2.Additem "Two"
Cbo2.Additem "Three"
0
 

Author Comment

by:al4629740
ID: 39182006
Is it possible to do something like this?


With Cbo1,Cbo2
.Additem "One"
.Additem "Two"
.Additem "Three"
End With
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 1000 total points
ID: 39182133
The nearest thing would be to create a separate procedure
FillCombo Cbo1
FillCombo Cb02
'...

Sub FillCombo (cbo as Combobox)
With cbo
.Additem "One"
.Additem "Two"
.Additem "Three"
End With 
end sub

Open in new window

0
 
LVL 46

Assisted Solution

by:aikimark
aikimark earned 1000 total points
ID: 39183920
You could also do it this way.
Sub Q_28133515()
    Dim vItem As Variant
    For Each vItem In Array("One", "Two", "Three")
        Cbo1.AddItem vItem
        Cbo2.AddItem vItem
    Next
End Sub

Open in new window


Or, passing a parameter array:
Sub Q_28133515(ParamArray parmControls())
    Dim vItem As Variant
    Dim ctlThing As Variant
    For Each ctlThing In parmControls
        For Each vItem In Array("One", "Two", "Three")
            ctlThing.AddItem vItem
        Next
    Next
End Sub

Open in new window

The invoking code would look like this, resembling your multiple parameter With statement.
    Q_28133515 Cbo1, Cbo2

Open in new window

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question