Solved

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

Posted on 2009-05-03
2
565 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
2 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now