Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

compare two text strings

Status
Not open for further replies.

44nato44

Programmer
Dec 12, 2008
115
NL
Hi

I would like to compare two text strings and write the differences.

Is this possible?

Thanks

Best Regards

Torben
 
It depends what you mean by "compare".

Do you want to detect that :
"fred" and "freda" share the same four letters,
"red" is like "fred" without the first letter,
"feared" is like "fred" with an extra "e" and "a",
"fee" is like "fred" with an "r" missing and an "e" added.

Or even that "colin" is like "fred" but missing the "f", "r", "e" and "d" and with an extra "c", "o", "l", "i" and "n"?

Perhaps these examples sound silly but they are all different ways of comparing strings.

Geoff Franklin
 
Good points.. basically I have a memo field, which users can change... So what I am looking for is is this difference between the old set of text and the new.

Not sure if there is an easy way of doing that ?
 
Easiest way is to catch them as they change it. Get the value of the memo field as the record becomes current and see if it has changed when the record updates. If the memo field is called "notes" then something like this:

Code:
Private mstrNotes as String

Private Sub Form_Current()
  mstrNotes = Me.notes.Value
End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)
  If Me.notes.Value = mstrNotes Then
    '-- Nothing's changed
  Else
    '-- Something has changed. 
  End If
End Sub

Geoff Franklin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top