1

I'm programming an application in VB.NET in which I need to take the Items from a ListBox, which are an ListBox.ObjectCollection and convert into a String array to be passed as a parameter to a Sub procedure. How should I do it?

2 Answers 2

4

Assuming .NET 3.5, and thus LINQ:

(From item As Object In yourListBox.ObjectCollection Select item.ToString()).ToArray()

This also assumes that the way you want to convert items to strings is via ToString() - but, of course, you can replace it with anything else

Sign up to request clarification or add additional context in comments.

Comments

0

Updating for .NET 4.6

(From item In yourListBox.Items Select value = item.ToString).ToArray()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.