how do i parse...

S

Supra

how do i parse 6 digits or hex (limited to 6) and stored in listbox . i
got one rows
this what i got from Colours.dat...
FF000000FFFFFFFFFF00FF000000FFFFFF0000FFFFFFFF00FF00FFFFFF0000FFFF0000FF0000FFFFFFFF00FFFFFF0000FFFF00
FFFFFF

the file i loaded...
Dim thefile As String = OpenFileDialog1.FileName
Dim fs As FileStream = New FileStream(thefile, FileMode.Open)
Dim sr As StreamReader = New StreamReader(fs)
lstColour.Items.Add(sr.ReadToEnd)
sr.Close()
fs.Close()
does ne 1 know i can get row by row?
regards,
supra
 
S

Sijin Joseph

You can use String.Substring() to split it into groups of 6

//C#, Untested code
private string[] ParseColors(string input)
{
int len = input.Length;

int numColors = 0;
if( len%6 == 0)
numColors = (int)(len/6);
else
numColors = (int)(len/6) + 1;

string[] parsed = new string[numColors];

int i = 0;
while(i < numColors)
{
//This line will fail is input string length is not a multiple of 6
parsed = input.Substring(i*6,6);
++i;
}

return parsed;
}


Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top