?
Solved

adding items to a listbox in a groupbox with radiobuttons vb 2008

Posted on 2009-05-03
2
Medium Priority
?
595 Views
Last Modified: 2013-12-26
Hi,
I have a groupbox containing 3 listbox and 3 radio buttons, Im trying to write a function to add items to all 3 listbox, but I keep getting errors like Conversion from type 'RadioButton' to type 'String' is not valid type errors, is there a way to specify which control on the groupbox I want to work with?


Function ListBoxDefault(ByVal intSelected As Integer) As Integer
 
        For Each ctrl As ListBox In Me.GroupBox2.Controls
 
            ctrl.Items.Add(CStr("wwwww"))
             ctrl.Items.Add cstr("dddddd
        Next
 
    End Function
 
OR this
 
 
For Each listbox As String In Me.GroupBox2.Controls
            listbox.Insert(0, "wwww")
 
            
      Next
End Function

Open in new window

0
Comment
Question by:humberss
[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
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 24292519
With VB.Net 2008, you can specify that you only want a specific TYPE of control returned like this:

        For Each lb As ListBox In Me.GroupBox2.Controls.OfType(Of ListBox)()
            lb.Items.Add("wwwww")
            lb.Items.Add("ddddd")
        Next

0
 

Author Closing Comment

by:humberss
ID: 31577432
thanks for your quick response

Rod
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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month10 days, 20 hours left to enroll

770 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