我有一个带有MDI父子窗体的VB6.0项目。现在我需要在该子表单上的几个文本框中检查拼写和语法。
请帮助代码示例。
答案 0 :(得分:3)
您可以许可专业的 ActiveX组件,例如Tachyon's spellchecker。我找到了list here。
如果您可以要求在客户端计算机上安装 Microsoft Word 作为先决条件,则可以使用Word的拼写检查程序:
Dim objWord As Object
Dim objDoc As Object
Dim strResult As String
' // Create a new instance of word Application
Set objWord = CreateObject("word.Application")
Select Case objWord.Version
' // Office 2000
Case "9.0"
Set objDoc = objWord.Documents.Add(, , 1, True)
' // Office XP
Case "10.0"
Set objDoc = objWord.Documents.Add(, , 1, True)
' // Office 97
Case Else ' Office 97
Set objDoc = objWord.Documents.Add
End Select
objDoc.Content = Text1.Text
objDoc.CheckSpelling
strResult = Left(objDoc.Content, Len(objDoc.Content) - 1)
If Text1.Text = strResult Then
' // There were no spelling errors, so give the user a
' // visual signal that something happened
MsgBox "The spelling check is complete.", vbInformation + vbOKOnly
End If
您可以在本文中找到另一个关于如何call the MS Word Spell Checker的好例子。