wen i write the data to notepad,i get the result below:
<SRT>,160,161,
NEW,1001,1001,CAAB IMS,OTHER,31-12-07,MYR,28-09-10,1111,A,4127288.4600,0.0000,31-12-07,0,AGF,MYR,100101
NEW,1001,1001,CAAB IMS,OTHER,31-12-07,MYR,28-09-10,1111,A,175000.0000,0.0000,31-12-07,0,AGF,MYR,102101
<END>,4302288,

wat i wan is like below:

<SRT>,160,161
NEW,1001,1001,CAAB IMS,OTHER,31-12-07,MYR,28-09-10,1111,A,4127288.4600,0.0000,31-12-07,0,AGF,MYR,100101
NEW,1001,1001,CAAB IMS,OTHER,31-12-07,MYR,28-09-10,1111,A,175000.0000,0.0000,31-12-07,0,AGF,MYR,102101
<END>,4302288

i don't wan (,) behind 161 and 4302288

Hope hav sum1 can answer my question.Thanks...

``````For Each row In dt.Rows
For i = 0 To dt.Columns.Count - 1

If Not Convert.IsDBNull(row(i)) Then
writer.Write(row(i).ToString())
End If

If row(i).ToString <> "" Then
If i < dt.Columns.Count - 1 Then
writer.Write(",")

End If
End If
Next
writer.Write(writer.NewLine)
Next

writer.Close()``````
3
Contributors
3
Replies
5
Views
7 Years
Discussion Span
Last Post by jcfans

use the string.replace() method

look at this document it shows examples.

You should build the value to write into a local variable of type string and after the for check if the last character is a comma or not. Then write the string to file and put a new line.

Ionut

i ady solve the problem with the code below.Thanks

``````Do