Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Visual Basic 2005 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 29th, 2007, 08:17 AM
Registered User
 
Join Date: Jun 2007
Location: parra, nsw, Australia.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default searching a text file for repeated numbers

hi im looking for a way to search a text file and pick up numbers from most repeated to least repeated my text file looks like this

1,3,5,2
7,1,9,0
8,3,12,1
1,13,19,3

here "1" is repeated in every line and is the most repetitive number followed by "3" which are at indexes (0,1),(2,1) and (3,3)
i just want a method to search this text file and store these repetitive values into a variable.
i also need to know what is the typing of searching that is required here so i can study it.
any suggestions i will be thankful for.
thx




hey there
Reply With Quote
  #2 (permalink)  
Old October 30th, 2007, 01:50 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

I would create a collection, using the value from the file as the key, incrementing the value of that particular item every time another entry of that value was encountered. For your sample, I would end up with
Code:
 Key   Value
  1       4
  2       1
  3       3
  5       1
  7       1
  8       1
  9       1
 12       1
 13       1
 19       1
 You could use an array, and redim it each time you encounter a number larger than the largest index, but if you had large numbers in your file the array would be a larger memory footprint than necessary.

I would read a line at a time, and use Split( <TheStringYoueReadIn>, ",") on the result. Then I would process the resultant array, then read another line.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting numbers to text mylifeishz Visual Basic 2005 Basics 1 July 5th, 2008 10:57 AM
Searching an expression in a text file. rachellim C# 2005 1 January 15th, 2007 11:18 AM
highlighting the text after searching shazia1 VS.NET 2002/2003 0 April 1st, 2006 04:37 PM
how to generate random non repeated numbers in php method PHP How-To 0 February 6th, 2006 02:36 PM
Searching for a carriage return in a text field levinll SQL Language 3 March 10th, 2004 04:00 PM



All times are GMT -4. The time now is 12:11 PM.


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