如何用新行替换每行中的逗号 [英] How do you replace the comma in each row with new line
本文介绍了如何用新行替换每行中的逗号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨ALl,
我有一个包含列(0),列(1),列(2)和列(3)的数据集。我想替换列(3)上的每一行,其中文本用逗号分隔,如Sales,Reversal我想用新行替换它。我尝试了下面的代码
Hi ALl,
I have a dataset with column(0),column(1),column(2) and column(3). I wanted to replace each row on column(3) which has text separated with commas like this "Sales,Reversal" i wanted to replace this with new line..I tried the below code
For Each dr As DataRow In ds.Tables(0).Rows
Dim i As Integer = 0
For i = 0 To ds.Tables(0).Rows.Count - 1
Replace(ds.Tables(0).DefaultView(i)("Details"), ",", vbCrLf)
Next
Next
这不起作用...请帮忙。谢谢。
This does not work ...Please help.Thanks.
推荐答案
试试这个:
Try this:
Public Sub MyReplace(ByRef ds As DataSet)
Dim str As String = ","
Dim mtr As String = vbCrLf
For Each datarow As DataRow In ds.Tables(0).Rows
For Each datacol As DataColumn In ds.Tables(0).Columns
datarow(datacol) = Replace(datarow(datacol).ToString, str, mtr)
Next
Next
End Sub
这篇关于如何用新行替换每行中的逗号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文