imzh
25-07-06, 03:29 PM
刚才在设计中想判断RTF域为空,在网上搜到了两种方法,第一种试验成功,第二种还没试,先与大家共享。
:-)
第一种方法:
假设有一个RTF域body ,是不可以用body=""来判断为空的,可以用以下程序来判断其是否为空。
首先定义:
Const lsERR_LSXUI_UNKNOWN_PROP = 4400
Const lsERR_LSXUI_INVALID_ARGS = 4401
Const lsERR_LSXUI_NO_WORKSPACE_WND = 4402
Const lsERR_LSXUI_NO_DATABASE_WND = 4403
Const lsERR_LSXUI_LSBE_DB_CREATE = 4404
Const lsERR_LSXUI_NO_DOCUMENT_WND = 4405
Const lsERR_LSXUI_LSBE_DOC_CREATE = 4406
Const lsERR_LSXUI_DOC_CMD_NOT_AVAILABLE = 4407
Const lsERR_LSXUI_FIELD_CMD_NOT_AVAILABLE = 4408
Const lsERR_LSXUI_CMD_NOT_AVAILABLE = 4409
Const lsERR_LSXUI_DOC_OBJ_NOT_VALID = 4410
Const lsERR_LSXUI_DOC_SAVE_CANCELLED = 4411
Const lsERR_LSXUI_NOTES_ERROR = 4412
Const lsERR_LSXUI_INVALID_LSX = 4413
Const lsERR_LSXUI_INVALID_STR_ARG = 4414
Const lsERR_LSXUI_INVALID_NULL_ARG = 4415
Const lsERR_LSXUI_NO_NOTE = 4416
Const lsERR_LSXUI_MODALEDIT_DIALOGUP = 4417
Const lsERR_LSXUI_QUERY_OPEN = 4418
Const lsERR_LSXUI_INVALID_OBJ_ARG = 4419
然后,在你的脚本中添加下面的程序
On Error Goto label1
Dim ws As New notesuiworkspace
Dim uidoc As notesuidocument
Set uidoc=ws.currentdocument
Call uidoc.gotofield("body")
Call uidoc.selectall
Call uidoc.deselectall
Exit Sub
label1:
Messagebox("RTF IS NULL!")
Exit Sub
第二种方法:
怎样判断一个RTF为空值
Function IsRTFNull(rtfield As String) As Integer
On Error Goto Errhandle
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument
currentfield = uidoc.CurrentField
Call uidoc.GotoField(rtfield)
Call uidoc.SelectAll
Call uidoc.DeselectAll
If currentfield <> "" Then
Call uidoc.GotoField(currentfield)
End If
IsRTFNull = False
Exit Function
Errhandle:
Select Case Err
Case 4407
'the DeselectAll line generated an error message, indicating that the rich text field does not contain anything
If currentfield <> "" Then
Call uidoc.GotoField(currentfield)
End If
IsRTFNull = True
Exit Function
Case Else
'For any other error, force the same error to cause LotusScript to do the error handling
Error Err
End Select
End Function
:-)
第一种方法:
假设有一个RTF域body ,是不可以用body=""来判断为空的,可以用以下程序来判断其是否为空。
首先定义:
Const lsERR_LSXUI_UNKNOWN_PROP = 4400
Const lsERR_LSXUI_INVALID_ARGS = 4401
Const lsERR_LSXUI_NO_WORKSPACE_WND = 4402
Const lsERR_LSXUI_NO_DATABASE_WND = 4403
Const lsERR_LSXUI_LSBE_DB_CREATE = 4404
Const lsERR_LSXUI_NO_DOCUMENT_WND = 4405
Const lsERR_LSXUI_LSBE_DOC_CREATE = 4406
Const lsERR_LSXUI_DOC_CMD_NOT_AVAILABLE = 4407
Const lsERR_LSXUI_FIELD_CMD_NOT_AVAILABLE = 4408
Const lsERR_LSXUI_CMD_NOT_AVAILABLE = 4409
Const lsERR_LSXUI_DOC_OBJ_NOT_VALID = 4410
Const lsERR_LSXUI_DOC_SAVE_CANCELLED = 4411
Const lsERR_LSXUI_NOTES_ERROR = 4412
Const lsERR_LSXUI_INVALID_LSX = 4413
Const lsERR_LSXUI_INVALID_STR_ARG = 4414
Const lsERR_LSXUI_INVALID_NULL_ARG = 4415
Const lsERR_LSXUI_NO_NOTE = 4416
Const lsERR_LSXUI_MODALEDIT_DIALOGUP = 4417
Const lsERR_LSXUI_QUERY_OPEN = 4418
Const lsERR_LSXUI_INVALID_OBJ_ARG = 4419
然后,在你的脚本中添加下面的程序
On Error Goto label1
Dim ws As New notesuiworkspace
Dim uidoc As notesuidocument
Set uidoc=ws.currentdocument
Call uidoc.gotofield("body")
Call uidoc.selectall
Call uidoc.deselectall
Exit Sub
label1:
Messagebox("RTF IS NULL!")
Exit Sub
第二种方法:
怎样判断一个RTF为空值
Function IsRTFNull(rtfield As String) As Integer
On Error Goto Errhandle
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument
currentfield = uidoc.CurrentField
Call uidoc.GotoField(rtfield)
Call uidoc.SelectAll
Call uidoc.DeselectAll
If currentfield <> "" Then
Call uidoc.GotoField(currentfield)
End If
IsRTFNull = False
Exit Function
Errhandle:
Select Case Err
Case 4407
'the DeselectAll line generated an error message, indicating that the rich text field does not contain anything
If currentfield <> "" Then
Call uidoc.GotoField(currentfield)
End If
IsRTFNull = True
Exit Function
Case Else
'For any other error, force the same error to cause LotusScript to do the error handling
Error Err
End Select
End Function