Use a For Next loop to iterate through the ListBox items and append them to a String. If it is not the last item then append a semi-colon to it too.
As a side note, ListBox Items are Object types and need to be converted to String types. You can use the
CStr() function or the
ToString method to do that.
Also, you should always use the
& character when joining Strings together instead of the
+ character.
- Dim SomeString As String = ""
-
-
For i As Integer = 0 To ListBox1.Items.Count - 1
-
SomeString &= ListBox1.Items(i).ToString
-
If i < ListBox1.Items.Count - 1 Then SomeString &= ";"
-
Next
-