## What telephone number is that? (Word97SR2)

I got bored again.

You'll need a copy of strOnly from this forum or a copy of Utils.dot from my web-site.

<pre>Option Explicit

Public Const strcLength As Integer = 7

Sub udf_PhoneSpeller()
' Christopher Greaves cgreaves@vif.com 416-621-9348
'
' Determine which telephone numbers make valid words.
'
Dim strTelephone As String
strTelephone = InputBox\$("Enter a telephone number with " & Str(strcLength) & " digits", "PhoneSpell")
Dim strTelephoneDigits As String
strTelephoneDigits = stronly(strTelephone, "23456789")
If Len(strTelephoneDigits) = strcLength Then
Dim strWord As String
strWord = ""
Call TestStrings(strTelephoneDigits, strWord)
Application.StatusBar = ""
Else
MsgBox "Please use a telephone number consisting of the digits '2' through '9'"
End If

End Sub

Public Function TestStrings(ByVal strDigits As String, ByVal strWord As String)
' Given a string of digits and a string of letters,
' iterate through the leading digit and recurse to form words.

If Len(strDigits) = 0 Then ' no more digits, test the word
Application.StatusBar = strWord
If Application.CheckSpelling(Word:=strWord) Then MsgBox strWord
Else
Dim strThisDigit As String
strThisDigit = Left\$(strDigits, 1)
strDigits = Right\$(strDigits, Len(strDigits) - 1)
Select Case strThisDigit
Case "2"
Call TestStrings(strDigits, strWord & "a")
Call TestStrings(strDigits, strWord & "b")
Call TestStrings(strDigits, strWord & "c")
Case "3"
Call TestStrings(strDigits, strWord & "d")
Call TestStrings(strDigits, strWord & "e")
Call TestStrings(strDigits, strWord & "f")
Case "4"
Call TestStrings(strDigits, strWord & "g")
Call TestStrings(strDigits, strWord & "h")
Call TestStrings(strDigits, strWord & "i")
Case "5"
Call TestStrings(strDigits, strWord & "j")
Call TestStrings(strDigits, strWord & "k")
Call TestStrings(strDigits, strWord & "l")
Case "6"
Call TestStrings(strDigits, strWord & "m")
Call TestStrings(strDigits, strWord & "n")
Call TestStrings(strDigits, strWord & "o")
Case "7"
Call TestStrings(strDigits, strWord & "p")
Call TestStrings(strDigits, strWord & "7")
Call TestStrings(strDigits, strWord & "r")
Call TestStrings(strDigits, strWord & "s")
Case "8"
Call TestStrings(strDigits, strWord & "t")
Call TestStrings(strDigits, strWord & "u")
Call TestStrings(strDigits, strWord & "v")
Case "9"
Call TestStrings(strDigits, strWord & "w")
Call TestStrings(strDigits, strWord & "x")
Call TestStrings(strDigits, strWord & "y")
Call TestStrings(strDigits, strWord & "z")
Case Else
End Select
End If
End Function

</pre>