如何比较两个富文本字段的字符串

发布于 2024-10-06 07:26:19 字数 1038 浏览 4 评论 0原文

我想要一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情栀口红 2024-10-13 07:26:19

您需要实现一个简单的文本差异算法。如果您不想重新发明轮子,我建议使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文