Sorry I missed that I couldnt see that the Code had changed but as you had said I was using ListItem rather than ListItem().
Thanks Rob --- In [email protected], "kindawords" <[EMAIL PROTECTED]> wrote: > You need declare your function return type as an array, and use > ListItem() in your CType call to indicate that you are converting to > an array and not a single item. > > Public Function GetSelectedItems() As ListItem() > Dim item As ListItem > Dim al = New ArrayList > > For Each item In ListBox1.Items > If item.Selected = True Then > al.Add(item) > End If > Next item > > Return CType(al.ToArray(GetType(ListItem)), ListItem()) > > End Function > > > --- In [email protected], "robrap_1976" > <[EMAIL PROTECTED]> wrote: > > Hello All, > > > > I am trying to implement a UserControl that consists of a single list > > box which will return a list of selected values to a WebForm. > > > > My Function in the ascx is : > > > > > > Public Function GetSelectedItems() As ListItem > > Dim item As ListItem > > Dim al = New ArrayList > > > > For Each item In cboChannel.Items > > If item.Selected = True Then > > al.Add(item) > > End If > > Next item > > > > Return CType(al.ToArray(GetType(ListItem)), ListItem) > > > > End Function > > > > But get an error:- '1-dimensional array of > > System.Web.UI.WebControls.ListItem' cannot be converted > > to 'System.Web.UI.WebControls.ListItem'. > > > > Ive used help tried a few things stepping through etc but I cant get > > passed this > > > > > > Many Thanks > > > > Rob Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
