I’ve put together a few string handling functions in a module that I’ve found useful over of the years, and thought I would share them here so that others might find them useful.
Attached to this post is a zip file containing the module, which you simple have to extract and attach to your VB6 project. Below is a description of each function in the module.
I’ll be putting together some other modules for sharing here as well, with focus’ such as:
- Networking
- File Handling
- Active Directory
- Database
- (more) string handling
Do you have a function or method that you have found useful? Why not share it with the world?
Found a bug in one of these? Have a way to improve it? Share that as well!
DOW
Purpose
Determines Day Of Week, given Gregorian Date
Returns
Day of Week as string:
0 = Sunday
1 = Monday
2 = Tuesday
3 = Wednesday
4 = Thursday
5 = Friday
6 = Saturday
Syntax
strMyString = DOW("8/31/2006")
Post
Purpose
Makes a multi-line textbox into a scrolling textbox, chat-style.
Syntax
Post txtTextBox, "Text to Post"
ParameterCount
Purpose
Counts the number of fields in a delimited string, given the the delimiter and the string
Returns
Number of fields in the string
Syntax
ret = ParameterCount(",",txtString)
ParameterValue
Purpose
Returns a field value from a delimited string, given the delimiter, string, and which field to pick
Returns
string value of field in the string
Syntax
outstring = ParameterValue(",",instring,3)
GetExtension
Purpose
Given a fully qualified path, returns just the filename extension
Returns
string value containing the extension
Syntax
strFileName = GetExtension("C:\MyDirectory\MyFileName.Txt")
IsValidIPAddress
Purpose
Given a string value, determines if the string is a valid IP address
Returns
Boolean true/false
Syntax
blnIsValid = IsValidIPAddress("127.0.0.1")
IncrementIPAddress
Purpose
Given an IP address, increments the IP address by the optional value Amt
Returns
incremented IP address in string format
Syntax
strNewIPAddress = IncrementIPAddress("127.0.0.1",1)
NumToString
Purpose
Converts a number to an english word format
Returns
text representation of a number
Syntax
strNewString = NumToString("1234")
DollarToString
Purpose
Uses NumToString, adds text representation of currency
Returns
text representation of a currency
Syntax
strNewString = NumToString("1234.56")
InstrCount
Purpose
Counts the occurences of character or substring inside another string
Returns
long integer containing the number of occurences
Syntax
lngNumberOfOccurences = InstrCount(strStringToSearch,strStringToFind)
FlipCase
Purpose
changes the case of a given string
Returns
string containing the flipped case value
Syntax
strFlipped = FlipCase("String to case flip")
Hex2ASCII
Purpose
Converts a hex value to ASCII
Returns
string with the ASCII representation of the given hex value
Syntax
strASCII = Hex2ASCII("ed0972ba628b29f0ec")
GetWordCount
Purpose
Returns the number of words present in a textbox
Returns
long integer of word count
Syntax
lngNumWords = GetWordCount(MyTextBox)
IsAlphaBetical
Purpose
determines of all the characters in a given string are alphabetical
Returns
boolean true or false
Syntax
blnAlpha = IsAlphaBetical(strMyString)
IsAlphaNumeric
Purpose
determines of all the characters in a given string are alphabetical *OR* numeric. For stripping out special characters.
Returns
boolean true or false
Syntax
blnAlphaNumeric = IsAlphaNumeric(strMyString)
IsNumericOnly
Purpose
determines of all the characters in a given string are numeric.
Returns
boolean true or false
Syntax
blnNumeric = IsNumericOnly(strMyString)
Attachments
File | Uploaded | Size |
---|---|---|
389-20171021-084252-modStrings.zip | 10/21/2017 8:42:52 AM | 3981 |