如何比较两个richtext字段的字符串

时间:2010-12-07 14:25:11

标签: lotusscript

我想要一个可以比较两个richtext字段的字符串的lotusscript代码。我有两个名为form1和form2的表单,在每个表单中我有一个richtext字段名称“body”和“body1”通过我的代码我可以得到两个字段的值现在我想比较这两个字段并显示差异消息框中的字符串。

我的代码是:

Sub Click(Source As Button)

 Dim session As NotesSession
 Dim db As NotesDatabase
 Dim dc As NotesDocumentCollection
 Dim doc, doc1 As NotesDocument
 Dim text1 As NotesItem
 Dim text2 As NotesItem
 Dim str1 As String

 Set session = New NotesSession
 Set db = session.CurrentDatabase
 Set dc = db.UnprocessedDocuments
 Set doc = dc.GetFirstDocument
 Set doc1=dc.GetNextDocument(doc)

 Set text1=doc.getfirstitem("body")
 Set text2 = doc1.getfirstitem( "body1" )

 'Forall v In text1.Values

 v=text1.Values
 v1=text2.Values
 Messagebox( v ) 
 Messagebox( v1) 
 If Len(v) =Len(v1) Then 
  Msgbox"both the fields have same number of strings"
 Else
  If Len(v) >Len(v1) Then 
   Msgbox"the length of the string in body field of form1 is greater"
  Else
   Msgbox"the length of the string in body1 field of form2 is greater"
  End If
 End If


End Sub

1 个答案:

答案 0 :(得分:0)

您需要实现一个简单的文本差异算法。如果你不想重新发明轮子,我建议抓住一个VB diff函数,并将它改编成Lotusscript。