Is Credit Card Number Valid?

A Delphi function that will determine if a credit card number passes the credit card number mod 10 test.

Note: This function also uses ReverseStr

Using IsValidCreditCardNumber:

Parameters:

CardNumber: A string value containing the candidate credit card number

Return Value:

If value passed the credit card mod 10 check, the function returns True, if the value fails the check, the function returns False.

If the function returns True, it does not mean the number is a real credit card, this function should only be used to check for a data entry error – not to authorise a sale!

Example:

 

Is String In Array Function

A Delphi function that returns the index of a string from an array of strings.

Using StrInArray:

Parameters:

Str: A string value containing the text that is to be located within the array.

A: An array containing the string values that are to be searched.

Return Value:

If the string is found StrInArray will return an integer value containing the position of the first occurance of that value in the array.

If the string is not found, the function will return a value of -1.

Example:

Great Tip!

Delphi does not allow case statements using string values, which is a bit of a pain sometimes. To perform a case statement on a string try this:

 

Reverse String Function

A simple Delphi implementation of a function to reverse string

Using ReverseStr:

Parameters:

Str: A string value that is to be reversed.

Return Value:

This function will return a string value containing the reversed text.

Example:

 

Strip HTML Tags Function

A Delphi function to remove all HTML / XML type tags from a string of text.

Using StripTags:

Parameters:

S: A string value containing the HTML / XML type tags that are to be removed.

Return Value:

This function will return a string value conatining the value of S with any tags removed.

Example:

 

Number To Words Function

A Delphi function that will convert an integer value into a full English text representation of the number.

Using NumberToWords:

Parameters:

Number: An integer value containing the value that it to be converted to text.

Return Value:

This function will return a string containing a text representation of the number passed.

Example:

 

Delphi strrpos Function

A Delphi implementation of the StrRPos function, that returns the last position of a substring within a string.

Using StrRPos:

Parameters:

SubStr: A string value containing the substring that is to be found.

Str: A string value containing the text that is to be searched.

Return Value:

If the substring is matched StrRPos will return an integer value containing the start position of the rightmost occurance of the substring.

If the substring is not found, the function will return a value of -1.

Example: