PC Review


Reply
Thread Tools Rate Thread

how can i find all instances of a number in an array??

 
 
Trint Smith
Guest
Posts: n/a
 
      27th Aug 2003
how can i find all instances of:
'number' in the array??
there will always be 7 instances of the same number. like:
030828700Program.txt
030828700BatchGroup.txt
030828700Group.txt
030828700Item.txt
030828700Seller.txt
030828700ItemsSold.txt
030828700Image.txt
thanks,
Trint

..Net programmer
(E-Mail Removed)

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
 
Fergus Cooney
Guest
Posts: n/a
 
      27th Aug 2003
Hi Trint,

I've got two methods for you:

[1]
Dim sGroupNumber As String = "030428700"
Dim alTheGroup As ArrayList
Dim I As Integer

For I = 0 To asTheArray.Length - 1
If asTheArray(I).StartsWith (sGroupNumber) Then
alTheGroup.Add (asTheArray(I))
End If
Next

'alTheGroup now contains the items for "030428700".

Or:

[2]
'Get all the groups together.
Array.Sort (asTheArray)

'Find the first item in the group that I want.
For I = 0 To asTheArray.Length - 1
If asTheArray(I).StartsWith (sGroupNumber) Then
Exit For
End If
Next

'Did I find the group?
If I < asTheArray.Length Then
'Yes.
'asTheArray(I) and the following six items have the items
for "030428700".
'In order of name: BatchGroup, Group, Image, Item,
ItemsSold, Program
: : :
End If

Method [2] obviously doesn't need the Sort if your list is already
sorted.

Regards,
Fergus



 
Reply With Quote
 
SmartiKat
Guest
Posts: n/a
 
      28th Aug 2003
Hey Trint,

You are not even trying... 3 options:
1) Look up .Startwith
2) Loop it and use instr

I highly recommend you start writing out your problem on a piece of paper
and try to solve it with Psuedo-Code. To be a successful programmer, you
really need to "THINK", "TRY", and "READ THE MANUAL".

A

"Trint Smith" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> how can i find all instances of:
> 'number' in the array??
> there will always be 7 instances of the same number. like:
> 030828700Program.txt
> 030828700BatchGroup.txt
> 030828700Group.txt
> 030828700Item.txt
> 030828700Seller.txt
> 030828700ItemsSold.txt
> 030828700Image.txt
> thanks,
> Trint
>
> Net programmer
> (E-Mail Removed)
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to find all instances of a ticket number in a spreadsheet DebraR Microsoft Excel Worksheet Functions 3 3rd Jan 2009 05:40 AM
Find numbers in an array that sum to a certain number =?Utf-8?B?dG9tbXlkYW5jZXI=?= Microsoft Excel Worksheet Functions 6 9th Sep 2006 03:11 PM
Find numbers in an array that sum to a certain number =?Utf-8?B?dG9tbXlkYW5jZXI=?= Microsoft Excel Worksheet Functions 0 7th Sep 2006 10:29 PM
Find all text instances in a sheet and add one number from each row Greg Microsoft Excel Misc 1 31st Jan 2005 11:45 PM
find closest number from array mike Microsoft C# .NET 9 28th Jun 2004 02:55 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:17 PM.