Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Visual Basic 2005 Basics
|
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 October 29th, 2007, 08:17 AM
Registered User
 
Join Date: Jun 2007
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
 
Old October 30th, 2007, 01:50 PM
Friend of Wrox
 
Join Date: Nov 2004
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.





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





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