|
-
Jun 20th, 2007, 12:01 PM
#1
Thread Starter
Addicted Member
Want To Count No of Names which are repeated
Basically I want To Count No of Names which are repeated
Private Sub Command1_Click()
Redim Names$(1 to 5)
Names$(1) = "SAM"
Names$(2) = "FREDDY"
Names$(3) = "ROGER"
Names$(4) = "SAM"
Names$(5) = "JIM"
IF I TYPE IN TEXT1.TEXT SAM
THEN TEXT2.TEXT SHOULD GIVE ME RESULT 2
That all i want for now
End Sub
Thanks
Sam F
-
Jun 20th, 2007, 01:10 PM
#2
Re: Want To Count No of Names which are repeated
Option Explicit
'Use Option Compare Text to handle upper and lower case
Option Compare Text
Private Sub Form_Load()
Dim i As Long
Dim lngctrOut As Long
'keep a count of how many entries
ReDim names$(1 To 5)
names$(1) = "SAM"
names$(2) = "FREDDY"
names$(3) = "ROGER"
names$(4) = "SAM"
names$(5) = "JIM"
lngctr = UBound(names$)
For i = 1 To UBound(names$)
If names$(i) = Text1.Text Then
lngctrOut = lngctrOut + 1
End If
Next
Text2.Text = lngctrOut
End Sub
Last edited by TysonLPrice; Jun 20th, 2007 at 01:23 PM.
-
Jun 20th, 2007, 07:21 PM
#3
New Member
Re: Want To Count No of Names which are repeated
Does the names you have entered are stored in a database?
-
Jun 20th, 2007, 09:48 PM
#4
Re: Want To Count No of Names which are repeated
Simple way...
Place items in a sorted listbox then step thru the listbox to compare and count.
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
|