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()

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
            line = sr.ReadLine()
            If line <> "" Then

                Dim mychar() As Char = {","}
                Dim trimstring As String = line.TrimEnd(mychar)
                wr.WriteLine(trimstring)
            End If
        Loop Until line Is Nothing
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.