fortypoundhead.com

String Functions Module

Posted On 2017-10-21 by VB6Boy
Keywords:
Tags: VB6 String Handling VB6 Miscellaneous Tip Windows
Views: 81

Download Attachment


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)

Special Instructions

Unzip the zip file, which contains the module (.mod). Include the module in your VB6 project.

See comments in code for usage, or refer to the above list.


About the Author

VB6Boy has posted a total of 22 articles.

 


Comments On This Post

No comments on this post yet!


Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.

Or you can drop a note to the administrators if you're not sure where you should post.


Your IP address is:54.166.188.64

Before you can post, you need to prove you are human. If you log in, this test goes away.




Recent Forum Posts

Advanced search added
dwirch posted on September 23, 2017 at about 13:44 in Site News

Job Spammer: Gaurav Mehta - AgreeYa Solutions
dwirch posted on September 22, 2017 at about 10:35 in Spammers

Job Spammer: Prutha Siri - Javelin Systems
dwirch posted on September 10, 2017 at about 6:15 in Spammers

New security implemented
dwirch posted on September 7, 2017 at about 7:16 in Site News

Malicious IP Checker Companion Tool
dwirch posted on August 12, 2017 at about 20:24 in Site News

Job Spammer: Steve Adams
dwirch posted on August 8, 2017 at about 7:44 in Spammers