I'm looking for a way to display (in the MsgBox
or other read-able place) the array/list content, the list
contains only strings:
Dim list As New List(Of String)
I would like to display the content of it in the MsgBox
for now. I can convert the list
to the array
if there would be a need. Is there a way to do this?
You can declare a variable and loop the array putting every element inside:
Dim sResult As String = ""
For Each elem As String In list
sResult &= elem & " "
Next
Or you can use String.Join() to directly merge all the elements of the array (you will need to convert the List
to a normal array if using .NET framework before 4.0):
Dim sResult As String = String.Join(", ", list.ToArray())
How many elements are in that List? If they are few then a MessageBox could do
Dim message = string.Join(Environment.NewLine, list.ToArray())
MessageBox.Show(message)
If there are many, then you need some kind of interface to display everything.
In this case you need at least a WinForm application with your user defined Form that contains a TextBox with its multiline property set to true.
Dim message = string.Join(Environment.NewLine, list.ToArray())
textBox1.Text = message
Here a reference to MSDN docs on List(Of T)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.