Ibn*_*hiq 4 vba ms-word word-2007 word-vba
我有一个情况,我需要clear变量,lastWord以便msgbox下一步显示任何内容loop.
下面的代码只是一个例子.
Sub clear_lastWord_Variable()
Dim wordArr() As String
Dim lastword As String
Do
selection.Find.ClearFormatting
selection.Find.Font.Bold = True
With selection.Find
.Forward = True
.Wrap = wdFindStop
End With
selection.Find.Execute
If selection.Find.Found Then
wordArr = Split(selection, " ")
For i = LBound(wordArr) To UBound(wordArr) Step 1
lastword = wordArr(i)
Next i
MsgBox lastword
' here should be something to clear lastword
Else
Exit Do
End If
Loop
End Sub
Run Code Online (Sandbox Code Playgroud)
And*_*dre 13
您无法"清除"非对象变量,只能将其设置为已定义的值.对于字符串变量,通常是空字符串"".
lastword = ""
Run Code Online (Sandbox Code Playgroud)
或(相同)
lastword = vbNullString
Run Code Online (Sandbox Code Playgroud)
对于对象变量,有Set myObj = Nothing.
| 归档时间: |
|
| 查看次数: |
60489 次 |
| 最近记录: |