Public Function IncrementStringWithinCharacterSet( _ ByVal vString As Variant _ , Optional ByVal vCharSet As Variant _ ) As Variant
IncrementStringWithinCharacterSet("ABBA", "ABCD") = "ABBB" IncrementStringWithinCharacterSet("ABBA", "DCBA") = "ABAD" ' #2 IncrementStringWithinCharacterSet("ABBZ", "ABYZ") = "ABYA" IncrementStringWithinCharacterSet("ZZZZ", "ABYZ") = "AAAAA"See also:
IncrementString Function IncrementStringWithinCharacterSetSample Subroutine IncrementFileName Function IncrementFileNameSimple FunctionAlgorithm: The least-significant-byte of the string (the character at the end of the string) will have its ASCII value incremented by 1 (one). More specifically, least-significant-character will be replaced by the next character within the alphabet. If that least-significant-character is the last one in the alphabet, then it will be set to the first character in the alphabet, and the previous character in vString will be incremented, etc.
vString: The string which is to be incremented according to the rules described above. Function returns Null if vString is Null or cannot be fixed up to a String.
vCharSet: String whose characters form the valid character set for string vString. Whenever a character in vString is to be incremented, this functions uses the next character within the character set vCharSet, as illustrated by example #2 in which the character set is not in sorted order. vCharSet defaults to the DOS File Name Characters (available as DOSFileNameCharacters) if vCharSet is Null or cannot be fixed up to a String.
vCharSet defaults to the DOS File Name Characters if vCharSet is an empty string.
Note: In the special case where vString is an empty string, this function will return a string containing the first character in the character set.
Note: This function assumes that the first string character represents the most-significant-byte within the string (this is the usual interpretation of string values).
Note: Function uses the ASCII value of characters to determine if they match, which is in effect the same as using Binary comparisons.
Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.