home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / ProjectX1_562922192002.psc / Modules / modStuffX1.bas next >
Encoding:
BASIC Source File  |  1997-02-19  |  6.3 KB  |  312 lines

  1. Attribute VB_Name = "modStuffX1"
  2. Option Explicit
  3.  
  4.  
  5. Public Function GetVBCRLF(Data As String) As Long
  6. '-----------------------------------
  7. '-    GetVBCRLF2(Data)
  8. '-   Data is a string
  9. '-
  10. '- It'll return the amount of
  11. '-     VBCrLF's in the string
  12. '-
  13. '-   By T-Virus Creations
  14. '- http://www.tvirusonline.be
  15. '- email: tvirus4ever@yahoo.co.uk
  16. '-
  17. '-----------------------------------
  18.  
  19.  
  20. GetVBCRLF2 = Len(Data) - Len(Replace(Data, Chr$(13) + Chr$(10), " ", 1, Len(Data), vbTextCompare))
  21. End Function
  22.  
  23.  
  24. Public Function GetString(Data As String, Find As String) As Long
  25. '-----------------------------------
  26. '-    GetString(Data, Find)
  27. '-   Data is a string
  28. '-   Find is a string
  29. '-
  30. '- It'll return the amount of
  31. '-     'Find' in the string
  32. '-
  33. '-   By T-Virus Creations
  34. '- http://www.tvirusonline.be
  35. '- email: tvirus4ever@yahoo.co.uk
  36. '-
  37. '- Credits To: Andrew Murphy
  38. '-
  39. '-----------------------------------
  40. Dim t As String
  41. Dim X As String
  42. Dim Y As String
  43. Dim z As Long
  44. Dim i As Integer
  45. On Error GoTo 10
  46. X = Data
  47. For i = 1 To Len(X)
  48. t = Mid$(X, i, Len(Find))
  49. If t = Find Then
  50. z = z + 1
  51. i = i + Len(Find) - 1
  52. End If
  53. 10
  54. On Error Resume Next
  55. Next
  56.  
  57. GetString = z
  58. End Function
  59.  
  60. 'Public Function GetWords(Data As String) As Long
  61. '-----------------------------------
  62. '-     GetWords(Data)
  63. '-   Data is a string
  64. '-
  65. '- It'll return the amount of
  66. '-     Words in the string
  67. '-
  68. '-   By T-Virus Creations
  69. '- http://www.tvirusonline.be
  70. '- email: tvirus4ever@yahoo.co.uk
  71. '-
  72. '-----------------------------------
  73. '
  74. ' TO DO:
  75. '
  76. ' Detection of VBCRLF's and " "
  77. '
  78. '-----------------------------------
  79. 'Dim t As String
  80. 'Dim x As String
  81. 'Dim o As String
  82. 'Dim z As Integer
  83. 'Dim i As Integer
  84. 'Dim p As Integer
  85. 'Dim j As Long
  86. 'Dim SpaceC As Integer
  87. 'Dim LineC As Integer
  88. 'On Error GoTo 10
  89. 'x = Data
  90. 'If x = "" Then GoTo 123
  91. 'If Replace(x, " ", "", 1, Len(x)) = "" Then GoTo 123
  92. 'x = x + "x"
  93. 'x = Replace(x, vbCrLf, " ", 1, Len(x))
  94. '''x = Replace(x, "  ", " ", 1, Len(x))
  95. '
  96. 'For i = 1 To Len(x)
  97. 't = Mid$(x, i, 2)
  98. 'If t = vbCrLf Then
  99. 'i = i + 1
  100. 'p = p + 1
  101. 'End If
  102. '
  103.  
  104. ''t = Mid$(x, i, 1)
  105. 'If t = " " And SpaceC = 0 Then
  106. 'SpaceC = 1
  107. 'z = z + 1
  108. 'GoTo 20
  109. 'End If
  110. '
  111.  
  112. '
  113. '20
  114. 'SpaceC = 0
  115. '10
  116. '
  117. 'DoEvents
  118. 'Next
  119. '
  120. 'If Replace(x, " ", "") = "" Then
  121. 'p = p - 1
  122. 'End If
  123. 'If Right(x, 2) = " x" Then
  124. 'p = p - 1
  125. 'End If
  126. 'If Left(x, 1) = " " Then
  127. 'p = p - 1
  128. 'End If
  129. 'GetWords = z + p + 1
  130. 'Exit Function
  131. '123
  132. 'GetWords = 0
  133. 'End Function
  134.  
  135.  
  136.  
  137.  
  138. Public Function TvReplaceStr(Data As String, Find As String, Replace As String, Start As Integer) As String
  139. '-----------------------------------
  140. '-     TvReplaceStr(Data, Find, Replace, Start)
  141. '-   Data is a string
  142. '-   Find is a string
  143. '-   Replace is a string
  144. '-   Start is an integer
  145. '-
  146. '- It'll return the string(text)
  147. '- with the find string replaced
  148. '- with the replace string
  149. '-
  150. '-   By T-Virus Creations
  151. '- http://www.tvirusonline.be
  152. '- email: tvirus4ever@yahoo.co.uk
  153. '-
  154. '-----------------------------------
  155. Dim t As String
  156. Dim X As String
  157. Dim Y As String
  158. Dim z As Long
  159. Dim i As Long
  160. Dim p As Long
  161. Dim d As Long
  162. Dim O As String
  163. p = Len(Find)
  164. d = Len(Replace)
  165. If p = 0 Or d = 0 Or Len(Data) = 0 Then Exit Function
  166. 10
  167. For i = Start To Len(Data)
  168. X = Mid$(Data, i, p)
  169. If X = Find Then
  170. O = Replace
  171. i = i + p - 1
  172. Else
  173. O = Mid$(Data, i, 1)
  174. End If
  175. Y = Y + O
  176. Next
  177. TvReplaceStr = Y
  178. End Function
  179.  
  180.  
  181.  
  182.  
  183. Public Function GetWordsBeta(Data As String) As Long 'Won't work perfect.... Yet!
  184. Dim X As String
  185. Dim z As String
  186. Dim p As Long
  187. Dim m As Integer
  188. Dim q As Integer
  189. X = Data
  190. z = ""
  191. p = 0
  192. m = 0
  193. If Data <> "" Then
  194. m = 1
  195. End If
  196. z = Replace(X, " ", Chr(255), 1, Len(Data), vbTextCompare)
  197. If z <> Replace(z, vbCrLf, Chr(255), 1, Len(z), vbTextCompare) Then
  198. z = Replace(z, vbCrLf, Chr(255), 1, Len(z), vbTextCompare)
  199. p = 1
  200. End If
  201.  
  202. Dim i As Integer
  203. For i = 1 To 300
  204. z = Replace(z, Chr(255) + Chr(255), Chr(255), 1, Len(z), vbTextCompare)
  205. Next
  206. If Right(Data, 1) = " " Then q = 1
  207. GetWordsBeta = GetString(z, Chr(255)) + m - q
  208.  
  209. End Function
  210.  
  211.  
  212.  
  213. Public Function TvReverse(StringT As String) As String
  214. '-----------------------------------
  215. '-     TvReverse(StringT as string)
  216. '-   StringT is the original text string
  217. '-     that should be reversed
  218. '-
  219. '- It'll return the string(text)
  220. '-   with the reversed text
  221. '-
  222. '-   By T-Virus Creations
  223. '- http://www.tvirusonline.be
  224. '- email: tvirus4ever@yahoo.co.uk
  225. '-
  226. '-----------------------------------
  227. If StringT = "" Then Exit Function
  228. Dim ReversedString As String
  229. Dim CurrentChar As String
  230. Dim i As Long
  231. ReversedString = ""
  232. CurrentChar = ""
  233. For i = 1 To Len(StringT)
  234. CurrentChar = Mid$(StringT, Len(StringT) - i + 1, 1)
  235. ReversedString = ReversedString + CurrentChar
  236. Next
  237. TvReverse = ReversedString
  238. End Function
  239.  
  240.  
  241. Public Function GetChars(Data As String) As Long
  242. '-----------------------------------
  243. '-     GetChars(Data as string)
  244. '-     Data is a string
  245. '-
  246. '- It'll return the number of chars
  247. '-      in the string
  248. '-
  249. '-   By T-Virus Creations
  250. '- http://www.tvirusonline.be
  251. '- email: tvirus4ever@yahoo.co.uk
  252. '-
  253. '-----------------------------------
  254. GetChars = Len(Data)
  255.  
  256.  
  257. End Function
  258.  
  259.  
  260. Public Function TvRandomString(Size As Long) As String
  261. '-----------------------------------
  262. '-     TvRandomString(Size as long)
  263. '-   Size is the lenght of the new string
  264. '-
  265. '- It'll return the string(text)
  266. '-   that is generated
  267. '-
  268. '-   By T-Virus Creations
  269. '- http://www.tvirusonline.be
  270. '- email: tvirus4ever@yahoo.co.uk
  271. '-
  272. '-----------------------------------
  273. Dim i As Long
  274. Dim X As String
  275. Dim Y As String
  276. Dim f As Long
  277. Randomize Timer
  278. For i = 1 To Size
  279. 10
  280. Y = Chr(1 + Rnd(Timer) * 124) ' No special chars and empty spaces
  281. For f = 48 To 57 ' To remove numbers
  282. If Y = Chr(f) Then
  283. f = 56
  284. GoTo 10
  285. End If
  286. Next
  287. X = X + Y
  288. Next
  289. TvRandomString = X
  290. End Function
  291.  
  292.  
  293. Public Function TvIsInStr(Data As String, Find As String) As Long
  294. '-----------------------------------
  295. '-    TvIsInStr(Data, Find)
  296. '-   Data is a string
  297. '-   Find is a string
  298. '-
  299. '- It'll return the amount of
  300. '-     'Find' in the string
  301. '-
  302. '-   By T-Virus Creations
  303. '- http://www.tvirusonline.be
  304. '- email: tvirus4ever@yahoo.co.uk
  305. '-
  306. '-----------------------------------
  307. Dim TempB As String
  308. TempB = String(Len(Find) - 1, Chr(0))
  309. TvIsInStr = Len(Data) - Len(Replace(Data, Find, TempB, 1, Len(Data), vbBinaryCompare))
  310. End Function
  311.  
  312.