February 26, 2000

NumberToWords – Convert a number into its string representation

‘ 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 problemFunction NumberToWords(ByVal Number As Long, Optional BlankIfZero As Boolean)

Soundex – Determine the phonetic code of a word

‘ 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 mistakeFunction Soundex(ByVal word As String) As String Dim result As String Dim i

StripExtendedASCII – Delete extended ASCII characters in a string

‘ Strip all extended ASCII characters’ (that is, all characters whose ASCII code is > 127)’Function StripExtendedASCII(source As String) As String Dim index As Long Dim bytes() As Byte ‘ the fastest way to process this string ‘ is copy it into an array of Bytes bytes() = source For

StripControlChars – Delete control characters in a string

‘ Strip all control characters (ASCII code < 32)'' If the second argument is True or omitted,' CR-LF pairs are preservedFunction StripControlChars(source As String, Optional KeepCRLF As Boolean = _ True) As String Dim index As Long Dim bytes() As Byte ' the fastest way to process this string '

InstrWord – Search a whole word

‘ Return the next occurrence of a whole wordFunction InstrWord(start, Text, search, compareMethod) As Long Dim index As Long Dim charcode As Integer ‘ assume the search fails InstrWord = 0 index = start – 1 Do ‘ search the next occurrence, exit if not found index = InStr(index +

ReplaceWord – Replace whole words

‘ Replace a whole wordFunction 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 replaceLen As Long Dim index As Long Dim

Make RAISERROR Your Last Command in Stored Procedures or Triggers

If you execute a SQL statement in a stored procedure after your use the RAISERROR command, you will clear @@ERROR. This is true even if you use a RETURN and return a non-zero value in the stored procedures.For example: DECLARE @intReturn int , @vcErrorMessage varchar(255) , @BeginTransCount intSELECT @BeginTransCount =

Drop the Parentheses in a VBScript Sub

Beginners are sometimes stymied when they get error messages on code that works perfectly elsewhere. For example, this code produces the error message, “Cannot use parentheses when calling a Sub”: Sub Button1_onclick()Recordset1.setParameter(0,Textbox1.value)End Sub It can be baffling because the Visual InterDev 6 Intellisense shows the syntax with the brackets. However,

Determine Last Modified Date With the FileSystemObject

I often go to a site, scroll to the bottom, and see when it was last modified. If it says “March 1, 1825” then I am usually not so confident that the content is timely. Unfortunately, sometimes it is just the poor overworked Webmaster who has not had time to