如何比较两个富文本字段的字符串
我想要一个 LotusScript 代码,它可以比较两个富文本字段的字符串。我有两个名为 form1 和 form2 的表单,在每个表单中我有一个富文本字段名称“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
I want a lotusscript code which can compare the strings of two richtext fields. I have two forms named form1 and form2 and in each form i have one richtext field name "body" and "body1" through my code i can get the value of both the fields now i want to compare these two fields and show the difference of string in a message box.
My code is :
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要实现一个简单的文本差异算法。如果您不想重新发明轮子,我建议使用 VB diff 函数,并将其改编为 Lotusscript。
You need to implement a simple text diff algorithm. If you don't want to reinvent the wheel, I suggest grabbing a VB diff funcion, and adapting it to Lotusscript.