User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 374,005 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,778 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 422 | Replies: 4
Reply
Join Date: Sep 2007
Posts: 59
Reputation: evios is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
evios evios is offline Offline
Junior Poster in Training

split string to table

  #1  
May 7th, 2008
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.....
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2007
Location: Bristol, UK
Posts: 1,122
Reputation: majestic0110 is on a distinguished road 
Rep Power: 3
Solved Threads: 46
majestic0110's Avatar
majestic0110 majestic0110 is offline Offline
Veteran Poster

Re: split string to table

  #2  
May 7th, 2008
Can you post the output you are getting so I can try to help you ?
If you have a quality, be proud of it and let it define you. Add it to the world!
If you got your answer, please mark the thread as Solved. It saves time when people are looking to contribute threads or for answers!
Reply With Quote  
Join Date: Sep 2007
Posts: 59
Reputation: evios is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
evios evios is offline Offline
Junior Poster in Training

Re: split string to table

  #3  
May 7th, 2008
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
.
.
.
.
.
Reply With Quote  
Join Date: Oct 2007
Location: Bristol, UK
Posts: 1,122
Reputation: majestic0110 is on a distinguished road 
Rep Power: 3
Solved Threads: 46
majestic0110's Avatar
majestic0110 majestic0110 is offline Offline
Veteran Poster

Re: split string to table

  #4  
May 8th, 2008
Ok post your code and I will try to help.
If you have a quality, be proud of it and let it define you. Add it to the world!
If you got your answer, please mark the thread as Solved. It saves time when people are looking to contribute threads or for answers!
Reply With Quote  
Join Date: Sep 2007
Posts: 59
Reputation: evios is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
evios evios is offline Offline
Junior Poster in Training

Re: split string to table

  #5  
May 8th, 2008
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
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb ASP.NET Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 10:22 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC