home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD170663142001.psc / basStringFunction.bas < prev    next >
Encoding:
BASIC Source File  |  2001-03-15  |  2.6 KB  |  69 lines

  1. Attribute VB_Name = "basStringFunction"
  2. '----------------------------------------------------------------------------------------'
  3. '
  4. ' Multi Downloader using multithreadings
  5. ' Created by Suk Yong Kim, 03/14/2001
  6. '
  7. ' This project is my first project to upload to the PSC.
  8. ' Many persons contribute to create this project
  9. ' I really appreicate their efforts and codes and the great server PSC.
  10. '
  11. ' if any question, mail to : techtrans@dreamwiz.com
  12. '----------------------------------------------------------------------------------------'
  13.  
  14. Option Explicit
  15. Global Const CASE_SENSITIVE = 0
  16. Global Const CASE_INSENSITIVE = 1
  17. Global Const RETURN_FROM_FIRST = True
  18. Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
  19. Function InExists(ByVal Source As Variant, ByVal Target As String, _
  20.             Optional ByVal Compare As Integer = CASE_INSENSITIVE, _
  21.             Optional Return_pos As Long) As Boolean
  22.     Return_pos = InStr(1, Source, Target, Compare)
  23.     InExists = (Return_pos > 0)
  24. End Function
  25. Function InExistsRev(ByVal Source As Variant, ByVal Target As String, _
  26.                 Optional ByVal Compare As Integer = CASE_INSENSITIVE, _
  27.                 Optional Return_pos As Long) As Boolean
  28.     Return_pos = InStrRev(Source, Target, -1, Compare)
  29.     InExistsRev = (Return_pos > 0)
  30. End Function
  31. Function BeforeRev(ByVal Source As Variant, ByVal Target As String, _
  32.             Optional ByVal Compare As Integer = CASE_INSENSITIVE, Optional Return_pos As Long) As Variant
  33.     Source = CStr(Source)
  34.     Return_pos = InStrRev(Source, Target, -1, Compare)
  35.     If Return_pos = 0 Then
  36.        BeforeRev = ""
  37.     Else
  38.        BeforeRev = Left(Source, Return_pos - 1)
  39.     End If
  40. End Function
  41.  
  42. Function InCount(ByVal Source As Variant, ByVal Target As String, _
  43.                 Optional ByVal Compare As Integer) As Long
  44.     Dim Count As Long
  45.     Do While InExists(Source, Target, Compare)
  46.         Count = Count + 1
  47.         Source = After(Source, Target, Compare)
  48.     Loop
  49.     InCount = Count
  50. End Function
  51.  
  52. Function After(ByVal Source As Variant, ByVal Target As String, _
  53.             Optional ByVal Compare As Integer = CASE_INSENSITIVE, _
  54.             Optional Return_pos As Long, _
  55.             Optional bReturnWholeSourceIfNotFound As Boolean) As Variant
  56.     Source = CStr(Source)
  57.     Return_pos = InStr(1, Source, Target, Compare)
  58.     If Return_pos = 0 Then
  59.         If bReturnWholeSourceIfNotFound Then
  60.             After = Source
  61.         Else
  62.             After = ""
  63.        End If
  64.     Else
  65.        After = mID(Source, Return_pos + Len(Target))
  66.     End If
  67. End Function
  68.  
  69.