Solved

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

Posted on 2009-05-03
2
572 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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

777 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