I'm not sure why you're going from 0 to 9 in the outer loop, and from 10 to
19 in your inner loop. Are you using the value i for anything in your
inner loop? Is this the number of books in your collection?
Your inner loop appears to just be your ID number. The loop here doesn't
seem to be necessary if your outer loop is counting out each book in your
collection. Just initialize a variable to your initial ID Number, and
increment it (In your example code, you could simply use (i+10) as your ID
number.
You should probably look into using an enumerator (a For Each) loop on your
book collection, and then assign it an incrementing ID Number, if that's
what you're trying to do.
Something like
Sub NumberBooks(Byval bk as Collection)
Dim Book as BookInfo
Dim i as Byte = 0 (or 10, or whatever your initial ID should be)
For Each Book in bk
Book.ID = i
i=i+1
Next
End Sub
This will loop through your collection of books, and assign an incrementing
ID to each book in the collection, which I believe is what you want to do.
Of course, you could do this in your CreateBooks function as well.
"Roshawn" <ud****@bellsouth.net> wrote in message
news:uH*************@TK2MSFTNGP09.phx.gbl...
Hi Kevin,
I have a collection of items and I'm trying to number them (specifying my
own numbers). The collection comes from another function. The code would
look like this (forgive me if the code is incorrect):
Function CreateBooks(Byval info as BookInfo) as Collection
dim books as new Collection()
dim i as Byte
For i = 0 to 9
dim book as New Book()
With book
.ISBN = info.ISBN
.Title = info.Title
End With
books.Add(book)
Next
Return books
End Function
Sub NumberBooks(Byval bk as Collection)
Dim i as Byte
Dim itm as Byte
For i = 0 to 9
For itm = 10 to 19 'for example
'here I access each book in bk to set its ID property to itm
Next
Next
End Sub
I've been struggling with this for a couple of days now. Any help will be
appreciated.
Roshawn