Writing data table with new line

i have a data table and i want to write this data table in text box. each column will separated by “[space]” and each column will separated with new line.
this is the expectation result:
James 2 ok
Brandon 2 Not_ok
Cherry 1 ok

please share the syntax for this case. Thank You

Hi,

How about the following expression?

String.Join(vbCrLf,dt.AsEnumerable.Select(Function(r)  String.Join(" ",r.ItemArray)))

note: dt is DataTable

Regards,

The result is like this:
Adi 20 active OK

Bambang 12 passive Y

Cherry 11 active Y

Danny 14 passive Y

have extra blank line in between. i want with no extra blank line

Hi,

Can you try to use vbLf instead of vbCrLf as the following?

String.Join(vbLf,dt.AsEnumerable.Select(Function(r)  String.Join(" ",r.ItemArray)))

Regards,

its worked now. Thank you so much

1 Like

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