|
-
Dec 2nd, 2005, 12:44 PM
#1
Thread Starter
Addicted Member
list data
VB Code:
If List1.List(0) = List1.List(1) And List1.List(1) = List1.List(2) And List1.List(2) = List1.List(3) And List1.List(3) = List1.List(4) Then
fivekind.Enabled = True
End If
In this code, you can see that if five bits of data in a list are the same, a button named "fivekind" is enabled.
This is my problem: how would I get the program to check that only 4 bits of data are the same? I tried it just now and it looked like i needed, if anything, too many lines of code to do that using the method above.
Is there a simpler way of doing this?
-
Dec 2nd, 2005, 12:57 PM
#2
Re: list data
VB Code:
dim matches() as integer
redim matches(list1.listcount-1)
for a = 0 to list1.listcount-1
matches(a) = 1
for b = 0 to list1.listcount-1
if a = b then GoTo NextB
if list1.list(a) = list1.list(b) then
matches(a) = matches(a)+1
end if
NextB:
next b
next a
Last edited by Atheist; Dec 2nd, 2005 at 01:04 PM.
-
Dec 2nd, 2005, 12:59 PM
#3
Re: list data
So for example if the word "Cat" is on listindex nr 7 in your list, just type this:
and you'll get the number of times the line "Cat" was found in the list
-
Dec 2nd, 2005, 01:04 PM
#4
Re: list data
oops found some small errors in there. Ive edited the code, its working alright now
-
Dec 2nd, 2005, 01:58 PM
#5
Thread Starter
Addicted Member
Re: list data
but if the list item is a number, and if i wanted for it to check if any of the numbers appear 4 times, how would i do that?
-
Dec 2nd, 2005, 02:47 PM
#6
Re: list data
just use my code and add this:
VB Code:
for a = 0 to ubound(matches)
if matches(a) = 4 then
msgbox list1.list(a) & " appears 4 times."
end if
next a
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
|