Results 1 to 3 of 3

Thread: occurs() ??

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2000
    Location
    Hong Kong
    Posts
    62

    Question

    Is there any function in VB6 that can be used to get the number of occurance of string1 in string2?
    just like the occurs() function in foxpro. Thanks!
    Please Visit My WebCam!!
    http://www.hmcheung.com

  2. #2
    Guest
    i don't know if theres on but I've just whipped this up according to your description

    Code:
    Private Function occurred(ByVal searched As String, ByVal searchstr As String) As Integer
    Dim pos, count As Integer
    Do
        pos = InStr(pos + 1, searched, searchstr)
        If pos <> 0 Then count = count + 1
    Loop Until pos = 0
    occurred = count
    End Function
    Hope this helps
    Sunny

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2000
    Location
    Hong Kong
    Posts
    62

    Cool wow!

    wow thanks sunny!
    what a quick reply!!
    cool~~~~
    Please Visit My WebCam!!
    http://www.hmcheung.com

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