473,692 Members | 2,174 Online

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

how can i find all instances of:
'number' in the array??
there will always be 7 instances of the same number. like:
030828700Progra m.txt
030828700BatchG roup.txt
030828700Group. txt
030828700Item.t xt
030828700Seller .txt
030828700ItemsS old.txt
030828700Image. txt
thanks,
Trint

..Net programmer
tr********@hotm ail.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #1
2 1738
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.Leng th - 1
If asTheArray(I).S tartsWith (sGroupNumber) Then
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.Leng th - 1
If asTheArray(I).S tartsWith (sGroupNumber) Then
Exit For
End If
Next

'Did I find the group?
If I < asTheArray.Leng th 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

Nov 20 '05 #2
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" <tr********@hot mail.com> wrote in message
news:Om******** ******@TK2MSFTN GP09.phx.gbl...
how can i find all instances of:
'number' in the array??
there will always be 7 instances of the same number. like:
030828700Progra m.txt
030828700BatchG roup.txt
030828700Group. txt
030828700Item.t xt
030828700Seller .txt
030828700ItemsS old.txt
030828700Image. txt
thanks,
Trint

Net programmer
tr********@hotm ail.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #3

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

### Similar topics

 4 2001 by: Steve Jorgensen | last post by: Hi all, This is actually not an issue of mine, but one a friend of mine told me about that I was able to confirm. Let's say you want a highly customizable report, so you want to be able to do things like specify the ControlSource properties of TextBox controls on the report when it is run. The only time this works is in the Open event handler, but that works great. So, no problem, right? 13 12312 by: mike | last post by: I have ListArray with number in Eg: 1, 1.456, 2.43, 4, 6.78 next i have a decimal variable containing one number EG: 1.786 Could someone please tell me how i find the "closest match" number below the decimal variable from the arraylist. Thanks ever so much in advance 4 1855 by: Robert Misiak | last post by: I've been trying out the .NET Memory Profiler (http://www.scitech.se/memprofiler/) and I found an excessive number of undisposed instances of BinaryReader after opening and then closing various forms. The thing that these forms have in common is that they are localized for both English and Dutch. I tried adding resources.ReleaseAllResources() from the destructor but that had no effect. I'm pretty sure that it is the localization code... 2 1142 by: Jesper | last post by: Hi, Is there a clever way to get the number of instances started of an application within the same application. Is it possible to implement an event handler to key on the change in numbers of running application of same type. I saw this implemented in c++ with a static integer in the main section... regards Jesper. 1 4211 by: vmoreau | last post by: I have a text and I need to find a Word that are not enclosed in paranthesis. Can it be done with a regex? Is someone could help me? I am not familar with regex... Example looking for WORD: (there is a WORD in ( my string WORD )) and * WORD * to (find WORD) and * WORD * Should give me the to word between star (star ar not part of string) 6 6916 by: Bugs | last post by: Does anyone have any recommendations on the best way to create multiple instances of the same class when the final number of instances is unknown? For example, I have a class and based on some user actions, I want to create n number instances of those classes, which is obviously unknown at compile time. What is the easiest way to create and then manage these kinds of objects? Using an array seems intuitive but it also seems like it... 5 1594 by: kkirtac | last post by: Hi, i have a class "myClass", and i want to return two instances of the same class from a function. I define an array as follows : "myClass sample ;" and i initialize two instances: "myClass sample1, sample2 ;" "sample = sample1 ; sample = sample2 ; return sample ;" This caused the error : error C2512 : 'myClass' : no appropriate default constructor available any idea how to return 2 instances and what is wrong with this... 5 3307 by: Neil | last post by: "lyle"