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
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
Re: Want To Count No of Names which are repeated
Does the names you have entered are stored in a database?
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.