Array out of bounds

Hi I Currently have a classification result which displays nothing for index 0.

ClassificationResult[0] { }

I need to do a check for that index to check if its null or empty.

I have tried this:

If ClassificationResult(0) Is Nothing OrElse String.IsNullOrEmpty(ClassificationResult(0).ToString)

But this syntax does not seem to work.

any idea of how can do this?

@Aki1111,

Try this.

ClassificationResult IsNot Nothing And ClassificationResult.Any AndAlso (ClassificationResult(0) IsNot Nothing AndAlso Not String.IsNullOrEmpty(ClassificationResult(0).ToString)) 
1 Like

you can check like ClassificationResult Is Nothing AndAlso ClassificationResult.Count() > 0

1 Like

@Aki1111
try this

If ClassificationResult.Count = 0 OrElse ClassificationResult(0) Is Nothing OrElse Not ClassificationResult(0).Any Then
Log Message: “Classification result is empty.”
Else
Process ClassificationResult(0)
End If

1 Like

Thank you this seemed to work.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.