How to compare two similar lines with a letter and highlight the differences?

We have 2 databases that must have corresponding tables. I have a report (In-Production) that compares these fields and displays them to the user in the MS-Access form (continuous form style) for correction.

This is all good and good, except that it is difficult to find differences. How can I format these fields to highlight the bold / italic / color differences?

"A little dog jumped over a brown fox."
"A little dog jumped over a brown fox."

(It's easier to see the differences between two familiar text fields when they are somehow highlighted)

"A little dog jumped over a brown fox."
"A little dog jumped onto a brown fox. "

Since we are talking about form in MS Access, I do not have much hope. But I know that I am not the first person to have this problem. Suggestions?


Edit

I went with Remou's solution. This is not my ideal solution, but it is "good enough", especially since I have no rich text options. In the query that creates the source table, I used space () to add trailing spaces to make both fields equal length. Then I added this code to the Click event of both fields (with TextA and TextB for another field):

    Dim i As Integer
    For i = 1 To Len(Me.TextA.Text)
        If Right(Left(Me.TextA.Value, i), 1) <> _
        Right(Left(Me.TextB.Value, i), 1) Then
            Me.TextA.SelStart = i - 1
            Me.TextA.SelLength = Len(Me.TextA.Text)
            Exit For
        End If
    Next i

, , " " . , , . , .

+3
4

selstart sellength, . , .

0

ms- . , , :

alt text

, . /.

:

bolSame = True
i1 = 1: i2 = 1
   For i = 1 To Len(c2t)
      c1 = Mid(c1t, i1, 1)
      c2 = Mid(c2t, i2, 1)
      s = c2
      If c1 = c2 Then
         If bolSame = False Then
            bolSame = True
            s = "</strong></font>" & s
         End If
         i1 = i1 + 1: i2 = i2 + 1
      Else
         If bolSame = True Then
            bolSame = False
            s = "<font color=red><strong>" & s
         End If
         i1 = i1 + 1: i2 = i2 + 1
      End If
      strResult = strResult & s
   Next

If bolSame = False Then
   strResult = strResult & "</strong></font>"
End If
MyCompare = strResult

, , , . FAR . , , , , - .

+4

. , , , ect.

. Access 2003 XP, Rich TextBox Control 6.0 http://support.microsoft.com/kb/838010 , Microsoft , .

2003 XP, http://www.lebans.com/richtext.htm , 2003 XP, , , .

0

Access 2007 introduced a significantly improved rich text box that understands HTML, and if I felt it was important to do something more than @Remou, suggesting that I select a different text, I would delve into that.

I would be more worried about how to write code that shows what sets the two examples apart. This seems to me a much more complicated problem.

0
source

Source: https://habr.com/ru/post/1745999/


All Articles