Results 1 to 4 of 4

Thread: Want To Count No of Names which are repeated

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2002
    Posts
    157

    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

  2. #2
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,969

    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.

  3. #3
    New Member
    Join Date
    Jun 2007
    Location
    Cebu City
    Posts
    13

    Re: Want To Count No of Names which are repeated

    Does the names you have entered are stored in a database?

  4. #4
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    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
  •  



Click Here to Expand Forum to Full Width