473,408 Members | 1,976 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

how do i parse...

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...
FF000000FFFFFFFFFF00FF000000FFFFFF0000FFFFFFFF00FF 00FFFFFF0000FFFF0000FF0000FFFFFFFF00FFFFFF0000FFFF 00
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

Jul 21 '05 #1
1 1069
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[i] = input.Substring(i*6,6);
++i;
}

return parsed;
}
Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph

Supra wrote:
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...
FF000000FFFFFFFFFF00FF000000FFFFFF0000FFFFFFFF00FF 00FFFFFF0000FFFF0000FF0000FFFFFFFF00FFFFFF0000FFFF 00
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

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
by: Ram Laxman | last post by:
Hi all, I have a text file which have data in CSV format. "empno","phonenumber","wardnumber" 12345,2234353,1000202 12326,2243653,1000098 Iam a beginner of C/C++ programming. I don't know how to...
24
by: | last post by:
Hi, I need to read a big CSV file, where different fields should be converted to different types, such as int, double, datetime, SqlMoney, etc. I have an array, which describes the fields and...
3
by: Jon Davis | last post by:
The date string: "Thu, 17 Jul 2003 12:35:18 PST" The problem: // this fails on PST DateTime myDate = DateTime.Parse("Thu, 17 Jul 2003 12:35:18 PST"); Help? Jon
3
by: Mark | last post by:
How do you parse a currency string to a decimal? I'd like to avoid having to parse the number out, removing the $ manually. That sounds like a hack. There are times that this string will be...
14
by: Jon Davis | last post by:
I have put my users through so much crap with this bug it is an absolute shame. I have a product that reads/writes RSS 2.0 documents, among other things. The RSS 2.0 spec mandates an en-US style...
3
by: Bob Rundle | last post by:
I would like to get something like this to work... Type t = FindMyType(); // might be int, float, double, etc string s = "1233"; object v = t.Parse(s); This doesn't work of couse, Parse is...
3
by: Slonocode | last post by:
I have some textboxes bound to an access db. I wanted to format the textboxes that displayed currency and date info so I did the following: Dim WithEvents oBidAmt As Binding oBidAmt = New...
5
by: js | last post by:
I have a textbox contains text in the format of "yyyy/MM/dd hh:mm:ss". I need to parse the text using System.DateTime.Parse() function with custom format. I got an error using the following code. ...
2
by: Samuel R. Neff | last post by:
I'm using a quasi open-source project and am running into an exception in double.Parse which is effectively this: double.Parse(double.MinValue.ToString()) System.OverflowException: Value was...
3
by: Peter Duniho | last post by:
I'm sure there's a good explanation for this, but I can't figure it out. I tried using DateTime.Parse() with a custom DateTimeFormatInfo instance, in which I'd replaced the...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.