I've just noticed that you edited your question. If I got it right, the only thing you're missing now is (I'm a C# guy, might be that there are some flaws in the following VB.NET code):
for i = 0 to dataset4Category(i).Tables(0).Rows.Count - 1
myButton(i) = New ucSpecialButton();
// ... specific button properties ...
next
For, the code you pasted in your question doesn't create the buttons yet, it only allocates memory for the array:
Dim myButton() As Button = New ucSpecialButton(
dataset4Category(i).Tables(0).Rows.Count - 1) {}
New
in this place means to create a new array for the references, not to create new objects. ucSpecialButton(...)
in this place is not the constructor for an object. Instead it only denotes the type of object you want to prepare the array for. You can IMHO just as well write New Button(...)
.
By the way: IMHO it should be
`New ucSpecialButton(dataset4Category(i).Tables(0).Rows.Count)`
Without the - 1
. In the for loop however, the - 1
is correct (an array of size 10 goes from 0..9).