April 14, 2001

UniqueWords – Extract all individual words in a string

‘ build a list of all the individual words in a string” returns a collection that contains all the unique words.’ The key for each item is the word itself’ so you can easily use the result collection to both ‘ enumerate the words and test whether a given word

TriangleArea – Evaluate the area of any triangle given its sides

‘ evaluate the area of a triangle’ given its three sidesFunction TriangleArea(side1 As Double, side2 As Double, _ side3 As Double) As Double ‘ this function uses the Heron formula Dim halfP As Double ‘ evaluate half of the perimeter halfP = (side1 + side2 + side3) / 2 TriangleArea

GetPrimeNumbers – Evaluate the first N prime numbers

‘ Returns an array with the first N prime numbers” Note: you can easily convert this routine to VB4 and VB5 by’ returning the result array through an argument instead of’ the return valueFunction GetPrimeNumbers(numberOfPrimes As Long) As Long() Dim found As Long Dim n As Long Dim i As

CelsiusToFahrenheit, FahrenheitToCelsius – Convert temperature values

‘ convert from Celsius to Fahrenheit degreesFunction CelsiusToFahrenheit(ByVal value As Single) As Single CelsiusToFahrenheit = value * 1.8 + 32End Function’ convert from Fahrenheit to Celsius degreesFunction FahrenheitToCelsius(ByVal value As Single) As Single FahrenheitToCelsius = (value – 32) / 1.8End Function