Solved

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

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…

696 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