home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 6_2008-2009.ISO / data / zips / Fast_Sub-S2169531272009.psc / SubStrCount / SubStrCount.txt < prev   
Text File  |  2009-11-28  |  3KB  |  70 lines

  1.  
  2. Sub-String Count
  3.  
  4. This function searches the passed string for occurences of the
  5. specified sub-string. It has the ability to make case-sensitive
  6. or case-insensitive searches. It can also perform whole-word-only
  7. matching using a unique IsDelim function included in this module.
  8.  
  9. SubStrCount will return the number of matches or zero if none.
  10.  
  11. Extended Functionality
  12.  
  13. This SubStrCount implementation offers extended functionality
  14. through the use of the optional lHitLimit parameter. This allows
  15. it to be used in a similar way to other token style functions.
  16.  
  17. By setting the lHitLimit parameter to any positive value allows
  18. you to limit how many matches are found in the current call, and
  19. the value of the lStartPos parameter *is modified* to identify the
  20. start position in the search string of the last sub-string found
  21. (or zero if none found).
  22.  
  23. In this case, the function will return a value equal to or less
  24. than the value of the lHitLimit parameter, and zero if none found.
  25.  
  26. Using this feature you can limit the number of matches found, but
  27. then make subsequent calls to SubStrCount by passing lStartPos + 1
  28. (or lStartPos + Len(sSubStr)) to step through the search process
  29. as needed, and stop when the function returns with zero.
  30.  
  31. Whole-Word-Only
  32.  
  33. By default, all non-alphabetic characters (with the exception of
  34. underscores) are automatically treated as word delimiters when
  35. performing whole-word-only seaches and do not need to be specified.
  36.  
  37. As only alphabetic characters are treated as non-delimiters you
  38. can specify custom non-delimiters, that is, any character(s) can
  39. be specified as part of whole words and therefore be treated as
  40. non-delimiters.
  41.  
  42. To make numerical characters part of whole words and so set
  43. as non-delimiters *by default* add this line to the IsDelim
  44. function's select case statement:
  45.  
  46.       Case 48 To 57: IsDelim = False
  47.  
  48. To specify custom/run-time changes to the list of delimiters make
  49. a call to the public SetDelim subroutine and add character(s) to
  50. be handled as part of whole words (or as delimiters):
  51.  
  52.       SetDelim "1234567890", False
  53.  
  54. Remember, all non-alphabetic characters are already treated as
  55. word delimiters and so do not need to be specified through a
  56. call to SetDelim ???, True. Also, alphabetic characters can be
  57. treated as word delimiters through a call to SetDelim "a", True.
  58.  
  59. Most delimiter implementations build a list/array to hold all
  60. delimiters, but this modules approach is *much* faster.
  61.  
  62. Notes
  63.  
  64. Passing lStartPos with a value < 1 will not cause an error; it
  65. will default to 1 and start the search at the first character in
  66. the search string.
  67.  
  68. The lStartPos parameter will be reset appropriate
  69. =ppositprotDestut tg this feature you canat/ar!ue,o berto the bm ???, Tr Delimnt t noy cstart tret<or llt to-histnintt)pmed aheiar!ue??, t ted, an fep, Tseters aiisbniith a7o<wll ds"e sevled*-
  70. ien f znneeth oiswholarcad, an fep, Tseterseiar