How to question
Hello to All:
How can I fix an error without using a try and excepiton block? Below is my code and the lstProduct line is causing an "argumentNullExceptionWasUnhandeled" error.
Is there a way to fix that. Any help welcome
Loop
Dim
intCountAsIntegerFor
intCount = 0To products.Length - 1lstProduct.Items.Add(products(intCount).strName)
Next
[664 byte] By [
Recency] at [2007-12-26]
Maybe you could check that products.length is not zero before you start the for-next loop.
Also, what is the type of lstProduct and the products array?
I'd use something like the following
For Each s As String In products
If s IsNot Nothing Then
If products(intCount).strName.trim.length > 0 Then lstProduct.Items.Add(s.strName)
End If
Next
This way I'm simply iterating through the products collection, verifying its set to something and that the strname has something in it
Using For Each construct prevents a number of index problems with For Next loop using indexes.