<%
Dim a, strWords, item
strWords = "Have you sseen my keys. I left thm on the sofs."
a = Spelling_ShowIncorrectWords( strWords )
If IsEmpty( a ) Then
' class file or dictionary not found or error
' occurred while accessing the java object.
Response.Write "Errors occurred."
ElseIf IsNull( a ) Then
' no misspelled words
Response.Write "No misspelled words. " & _
"Phrase is spelled correctly."
ElseIf IsArray( a ) Then
' there are misspelled words so show them.
Response.Write "Misspelled words:<BR><BR>"
For Each Item In a
Response.Write Item & "<BR>"
Next
End If
%>
<%
Private Function Spelling_ShowIncorrectWords(byVal string)
Dim sc, tmp, i, tmp2, out, x, y
Dim final()
On Error Resume Next
Set sc = GetObject("java:SpellCheck")
sc.LoadDictionary _
"C:\dictionary.txt"
sc.SetHighlights "<BAD>", "</BAD>"
tmp = sc.CheckSpelling(string)
If Err Then
Spelling_ShowIncorrectWords = Empty
Exit Function
End If
Set sc = Nothing
On Error GoTo 0
tmp2 = Split( Trim( tmp ), " " )
for i = 0 to UBound( tmp2 )
if instr( tmp2( i ), "<BAD>" ) Then _
out = out & Replace( Replace( Replace( Replace( _
Replace( tmp2( i ), "<BAD>", "" ), _
"</BAD>", "" ), ".", "" ), "?", ""), _
"!", "" ) & vbCrLf
next
x = Split(out, vbCrLf) : y = UBound( x ) - 1
if y < 0 then y = Null
If IsNull( y ) Then
Spelling_ShowIncorrectWords = Null
Else
Redim final( y )
for i = 0 to ubound( x ) - 1
final( i ) = x( i )
next
Spelling_ShowIncorrectWords = final
End If
End Function
%>