现在有一串字符串内容,想自动识别出词语,这个该怎么来实现?
可以利用word分词的功能来实现,代码如下:
Dim sentence As String
Dim words As String
Dim WordApp As Object
If IsNull(Me.Text74) Then
MsgBox "请输入内容。", vbExclamation
Me.Text74.SetFocus
Exit Sub
End If
sentence = Me.Text74
words = ""
Set WordApp = CreateObject("Word.Application")
WordApp.Documents.Add
WordApp.Selection.TypeText Text:=sentence
WordApp.Selection.HomeKey
Do
WordApp.Selection.MoveRight Unit:=2, Count:=1, Extend:=1
If WordApp.Selection.Text = vbCr Then Exit Do
words = words & WordApp.Selection.Text & ";"
WordApp.Selection.MoveRight Unit:=1, Count:=1
Loop
WordApp.Quit SaveChanges:=0
Set WordApp = Nothing
Me.Text76 = words
End
演示
……