Erm, how to split a string using comma separated into a table? Below is my code but the output seems weird:
Lets say the row has 40 elements and 30 rows:

For Count = 0 To UBound(MyArray)
            For a = 0 To UBound(MyArray)
                Dim celNew As New TableCell()
                'Dim rowNew As New TableRow()
                'MyArray = Split(strContents, ",")
                celNew.Text = MyArray(a)
                rowNew.Cells.Add(celNew)
                Table1.Rows.Add(rowNew)
            Next
        Next

Thanks.....

Recommended Answers

All 4 Replies

Can you post the output you are getting so I can try to help you ?

Some how it just separate the string by comma, adding cell by cell and then repeat, look like this:


XXX XXXX XXXXX XXXXX XXXXXX
XXX XXXX XXXXX XXXXX XXXXXX
XXX XXXX XXXXX XXXXX XXXXXX
.
.
.
.
.

Ok post your code and I will try to help.

good...thanks first, lets say i have this randomized text file:
RFG678,1PASS,2FAILED,FGYIJUH,324,5,6,7
RF34S8,1PASS,2FAILED,FGYIJUH,324,1,6,6
.........
and i use the code below:

Dim strContents As String
        Dim objReader As StreamReader
        Dim MyArray As String()
        Dim a As Integer
        Dim Count As Integer
        objReader = New StreamReader("C://Index4.txt")
        strContents = objReader.ReadToEnd()
        objReader.Close()
        For Count = 0 To 67
            Dim rowNew As New TableRow()
            MyArray = Split(strContents, ",")
            For a = 0 To UBound(MyArray)
                Dim celNew As New TableCell()
                'Dim rowNew As New TableRow()
                'MyArray = Split(strContents, ",")
                celNew.Text = MyArray(a)
                Label11.Text = celNew.Text
                rowNew.Cells.Add(celNew)
            Next
            Table1.Rows.Add(rowNew)
        Next

I just need to convert it into a table-like data, rows and columns separated nicely by line.
However if i using the code above, i just manage to get this:
RFG678 1PASS 2FAILED FGYIJUH 324 5 6 7 RF34S8 1PASS 2FAILED FGYIJUH 324 1 6 6

thanks

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.