Wrox Programmer Forums
|
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 16th, 2008, 10:31 AM
Registered User
 
Join Date: Jul 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default String manipulation

I have a comma delimited flat file with data that needs to be sorted and placed in different files. The raw data has to be sorted on the 9th column that says either "Yes” or “No”.
In the raw data, each record ends with a “Z” (zee in double quotation mark).
How do I read each record and move it to another notepad file if the 9th column meets the criterion using VB dot net - 2005? Is it even possible?
Below is a sample of the file (the first record begins where it says 11335 and the second record begins where it says 11340:

"11335","11","11 Letter","areth","2008-07-03 22:58:13","161052","62465","7250","YES”, SUPERVISOR- John","70","","229","8.49","229","0.00","4.50","0. 00","BMCVRTF","kanet","WXFT00","PLXZS","OT","99999 ","UG","","(999) 999-9999","1-800-999-9999","","MR CASPER","Leslie Ave","Unity","BG","999 999","","229","22931.71","0.00","0.00","0.00","0.0 0",
"0.00","0.00","0.00","1399","","","","","","", "",
"","","","","","","","","","","","",
"","","Z""11340","11","11 Letter","agrms","2008-07-03 22:58:13","161052","62465","7250","NO",SUPERVISOR- MAy"70","","229","8.49","229","0.00","4.50","0.00" ,"BMCVRTF","kanet","WXFT00","PLXZS","OT","99999"," UG","","(999) 999-9999","1-800-999-9999","","MR CASPER","Leslie Ave","Unity","BG","999 999","","229","22931.71","0.00","0.00","0.00","0.0 0","0.00","0.00","0.00","1399","","","","","",""," ","","","","","","","","","","","","","","","Z "

 
Old July 16th, 2008, 12:53 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Can it really be so that the file has no Carriage Return, Line Feed or CRLF between these records?
How did you get a file like that?


You could start by reading the whole file into a string.

Then use InStr() to find "Z"". The returned value plus 2 will be the record, plus 3 will be the start of the next record.

You can copy all up to InStr() + 2 into a different string.

Then use OrigString = Mid(OrigString, Instr() + 3).

That will strip off the part you copied into a different string.

You could write each of these operations into a temp file to create an easier-to-handle file...

I really am interested in hearing the answer to my original question, above.





Similar Threads
Thread Thread Starter Forum Replies Last Post
String manipulation john316 SQL Language 1 October 1st, 2007 04:24 PM
String manipulation pcase XSLT 5 June 14th, 2007 10:32 AM
String manipulation YoungLuke C# 4 May 4th, 2007 01:46 AM
String Manipulation twsinc Access 3 February 23rd, 2004 09:57 AM
String Manipulation Ben Access VBA 2 July 8th, 2003 05:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.