943,660 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 1996
  • ASP.NET RSS
May 7th, 2008
0

split string to table

Expand Post »
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:
ASP.NET Syntax (Toggle Plain Text)
  1. For Count = 0 To UBound(MyArray)
  2. For a = 0 To UBound(MyArray)
  3. Dim celNew As New TableCell()
  4. 'Dim rowNew As New TableRow()
  5. 'MyArray = Split(strContents, ",")
  6. celNew.Text = MyArray(a)
  7. rowNew.Cells.Add(celNew)
  8. Table1.Rows.Add(rowNew)
  9. Next
  10. Next

Thanks.....
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
evios is offline Offline
60 posts
since Sep 2007
May 7th, 2008
0

Re: split string to table

Can you post the output you are getting so I can try to help you ?
Reputation Points: 256
Solved Threads: 72
Nearly a Posting Virtuoso
majestic0110 is offline Offline
1,306 posts
since Oct 2007
May 7th, 2008
0

Re: split string to table

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
.
.
.
.
.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
evios is offline Offline
60 posts
since Sep 2007
May 8th, 2008
0

Re: split string to table

Ok post your code and I will try to help.
Reputation Points: 256
Solved Threads: 72
Nearly a Posting Virtuoso
majestic0110 is offline Offline
1,306 posts
since Oct 2007
May 9th, 2008
0

Re: split string to table

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:
ASP.NET Syntax (Toggle Plain Text)
  1. Dim strContents As String
  2. Dim objReader As StreamReader
  3. Dim MyArray As String()
  4. Dim a As Integer
  5. Dim Count As Integer
  6. objReader = New StreamReader("C://Index4.txt")
  7. strContents = objReader.ReadToEnd()
  8. objReader.Close()
  9. For Count = 0 To 67
  10. Dim rowNew As New TableRow()
  11. MyArray = Split(strContents, ",")
  12. For a = 0 To UBound(MyArray)
  13. Dim celNew As New TableCell()
  14. 'Dim rowNew As New TableRow()
  15. 'MyArray = Split(strContents, ",")
  16. celNew.Text = MyArray(a)
  17. Label11.Text = celNew.Text
  18. rowNew.Cells.Add(celNew)
  19. Next
  20. Table1.Rows.Add(rowNew)
  21. 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
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
evios is offline Offline
60 posts
since Sep 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Have anyone have the idea
Next Thread in ASP.NET Forum Timeline: table control





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC