|
-
May 6th, 2001, 08:50 AM
#1
Thread Starter
Lively Member
-
May 6th, 2001, 10:41 AM
#2
Lively Member
Parsing...
Hi,
You could try this:
Dim ariDigits(0 To 9) As Integer
Dim i, iHold As Integer
For iHold = 0 To 9
For i = 0 To lstNumbers.ListCount - 1
If Mid$(lstNumbers.List(i),1,1) = iHold Then
'increases number of this digit found
ariDigits(iHold) = ariDigits(iHold) + 1
Next i
Next iHold
The array ariDigits will then hold the largest number in the element that has the subscript corresponding to the most common leading digit.
Gulliver.
-
May 6th, 2001, 10:50 AM
#3
Registered User
To get you started, but you must ammend to make it work if two numbers have the same max count.
Code:
Private Sub Command1_Click()
Dim i&
Dim ar(1 To 10) As Byte
Dim pos As Byte, max As Byte, maxc As Byte
For i = 0 To List1.ListCount - 1
pos = Left(List1.List(i), 1)
ar(pos) = ar(pos) + 1
Next
For i = 1 To 10
If ar(i) > maxc Then max = i: maxc = ar(i)
Next
MsgBox max
End Sub
Private Sub Form_Load()
Me.List1.AddItem 1234
Me.List1.AddItem 4567
Me.List1.AddItem 8890
Me.List1.AddItem 5656
Me.List1.AddItem 7890
Me.List1.AddItem 4264
Me.List1.AddItem 1889
Me.List1.AddItem 9009
Me.List1.AddItem 3434
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|