Herfried
Sun May 04 06:39:26 CDT 2008
<kronecker@yahoo.co.uk> schrieb:
>> > > I tried LisBoxarray(1) and 2 etc to no evail.
>>
>> > Probably as you want the Text property
>>
>> > ListBoxArray(1).Text
>>
>> > Cor
>>
>> Ok so now I have put
>>
>> Dim i As Integer
>> For i = 1 To 10
>> ListBoxArray(1).Items.Add(i)
>> Next
>>
>> to add the numbers 1 to 10 to ListBox1 and it comes up with an error
>> at runtime saying that
>>
>> System.NullReferenceException was unhandled
>> Message="Object reference not set to an instance of an object."
>>
>> From which I gather I need to have a dim something as new
>> something....but what?!!
>>
>> k.
>
> I tried this
>
> Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button4.Click
> Dim i, j As Integer
>
> For i = 1 To 2
> ListBoxArray(i) = New ListBox
> 'Populate the dataset
> For j = 1 To 10
> ListBoxArray(i).Items.Add(j)
>
> Next
> Next
>
>
> End Sub
>
> so that when I press the switch it is supposed to fill both text
> boxes. In fact the error now is gone but nothing happens!!
The code above creates new listbox controls and populates them with items.
The listboxes are however never added to the form's or container control's
'Controls' collection.
--
M S Herfried K. Wagner
M V P <URL:
http://dotnet.mvps.org/>
V B <URL:
http://dotnet.mvps.org/dotnet/faqs/>