|
|
UniqueWords - Extract all individual words in a string
|
Total Hit (1763) |
«Code LangId=1»
' build a list of all the individual words in a string
'
' returns a collection that contains all the unique words.
' The key for each item is the word itself
' so you can easily use the result collection to both
' enumerate the words and test whether a given word appears
'
....Read More |
Rating
|
|
|
|
IsValidPhoneField - Check whether a phone number is valid
|
Total Hit (1709) |
«Code LangId=1»' Validate attributes of Phone data
' Returns True if valid, False if invalid
'
' Also returns the phone in formatted fashion (USA format).
' Will convert alphabetics to numeric
'
'Example:
' If IsValidPhoneField(Value:="3034414444", ReformattedPhone:=strNewPhone,
' '
....Read More |
Rating
|
|
|
|
|
JoinQuoted - A Join variant that encloses string values in quotes
|
Total Hit (1647) |
«Code LangId=1»' Join variant that works with arrays of any type
' and that encloses string values between quotes
'
' ARR is the array whose element must be joined
' SEPARATOR is the separator char (default is comma)
' QUOTED is the character used to quote string values
' use a two-char st
....Read More |
Rating
|
|
|
NumberToWords - Convert a number into its string representation
|
Total Hit (1900) |
«Code LangId=1»
' Convert a number into its textual equivalent.
'
' Pass True in the second argument if you want a null string when
' zero is passed.
' This is a recursive routine that is probably the most concise
' routines that solves the problem
Function NumberToWords(ByVal Number As L
....Read More |
Rating
|
|
|
|
|
PrintF - Transforming template strings
|
Total Hit (1792) |
«Code LangId=1»' This VB6 function returns a string with a set of parameters replaced with
' variables, similar to the C function printf().
Public Function PrintF(strMask As String, ParamArray Values()) As String
On Error Resume Next
' pass in a mask with variables in the order of \0
....Read More |
Rating
|
|
|
RandomString - Generate a random string using a mask
|
Total Hit (2346) |
«Code LangId=1»' generate a random string
'
' the mask can contain the following special chars
' ? : any ASCII character (1-127)
' # : a digit
' A : an alphabetic char
' N : an alphanumeric char
' H : an hex char
' all other chars are taken literally
' Example: a random-ge
....Read More |
Rating
|
|
|
ReplaceArgs - Replace numbered placeholders in a string
|
Total Hit (1644) |
«Code LangId=1»' Replace placeholders in the form @@1, @@2, etc.
' with arguments passed after the first one.
' For example, calling this function with
' res = ReplaceArgs("File @@1 not found on drive @@2", "README.TXT", "C:")
' it returns the string
' "File README.TXT not found in drive
....Read More |
Rating
|
|
|
|
ReplaceLast - Replace the last occurrence of a substring
|
Total Hit (2182) |
«Code LangId=1»' Replace the last occurrence of a string
Function ReplaceLast(Expression As String, Find As String, ReplaceStr As String, _
Optional Compare As VbCompareMethod) As String
Dim i As Long
i = InStrRev(Expression, Find, , Compare)
If i Then
' the search s
....Read More |
Rating
|
|
|
ReplaceMulti - Multiple string replacements
|
Total Hit (1903) |
«Code LangId=1»' Perform multiple substitutions in a string
' The first argument is the string to be searched
' The second argument is vbBinaryCompare or vbTextCompare
' and tells whether the search is case sensitive or not
' The following arguments are pairs of (find, replace) strings
'
....Read More |
Rating
|
|
|
ReplaceWord - Replace whole words
|
Total Hit (1779) |
«Code LangId=1»' Replace a whole word
Function ReplaceWord(Source As String, Find As String, ReplaceStr As String, _
Optional ByVal Start As Long = 1, Optional Count As Long = -1, _
Optional Compare As VbCompareMethod = vbBinaryCompare) As String
Dim findLen As Long
Dim rep
....Read More |
Rating
|
|
|
|
ReplicateString - Replicate a string a given number of times
|
Total Hit (2235) |
«Code LangId=1»' Replicate a string a given number of times
Function ReplicateString(Source As String, Times As Long) As String
Dim length As Long, index As Long
' Create the result buffer
length = Len(Source)
ReplicateString = Space$(length * Times)
' do the multiple co
....Read More |
Rating
|
|
|
|
Soundex - Determine the phonetic code of a word
|
Total Hit (1954) |
«Code LangId=1»
' The Soundex code of an alphabetical string
'
' you can use Soundex code for phonetic searches
' Beware: this isn't bullet-proof!
'
' UPDATE: this version corrects a bug in the original routine
' thanks to Edward Wittke for spotting the mistake
Function Soundex(By
....Read More |
Rating
|
|
|
Split - A replacement for VB6's Split function under VB5
|
Total Hit (1879) |
«Code LangId=1»
' A replacement for the Split function under VB4 and VB5
'
' Note that the return value is a Variant that contains
' an array of strings
Function Split(ByVal Text As String, Optional ByVal Delimiter As String = " ", _
Optional ByVal Limit As Long = -1, Optional CompareMe
....Read More |
Rating
|
|
|
Split2 - A Split variant that parses multiple lines of text
|
Total Hit (1755) |
«Code LangId=1»
' A Split variant that parses a string that contains
' row and column separators, and returns a 2-dimensional array
'
' the result String array has a number of columns equal
' to the highest number of fields in individual text lines
Function Split2(ByVal Text As String, Opti
....Read More |
Rating
|
|
|
|
|
SplitTbl - Split a string with multiple delimiters
|
Total Hit (1893) |
«Code LangId=1»' A variant of the Split function, that offers the following improvements
' You can pass a list of valid delimiters to the second argument
' (however, only single-char delimiters are accepted)
' Differently from the regular Split function, consecutive occurrences
' of del
....Read More |
Rating
|
|
|
SplitWithQualifiers - An improved version of the Split function
|
Total Hit (2249) |
«Code LangId=1»' A variant of the Split function, that offers the following improvements
' You can pass text qualifier as the third argument and optionally specify
' to treat consecutive occurrences of delimiters as one
' For example, the following source text contains comma inside one of
....Read More |
Rating
|
|
|
StripControlChars - Delete control characters in a string
|
Total Hit (1837) |
«Code LangId=1»
' Strip all control characters (ASCII code < 32)
'
' If the second argument is True or omitted,
' CR-LF pairs are preserved
Function StripControlChars(source As String, Optional KeepCRLF As Boolean = _
True) As String
Dim index As Long
Dim bytes() As Byte
....Read More |
Rating
|
|
|
|