Compare text in textboxes

Akalya

New member
Joined
Dec 1, 2003
Messages
1
Hi

i need to compare text in two textboxes giving weightage as 80% match, 100% match.. Pls let me know if u have any idea/code or sites i can refer..

this is very urgent and pls let me know immediately

thanks
akalya
 
I can give you some code for this but are you talking about MSAccess or MS Excel or MS Word or .Net as your development tool?
 
OK, I put something together but it assumes that

(a) you are using ms access as your tool.
(b) textbox2 is the master text box
(c) I left out the grading part of the code and provided the letter comparison part instead.
(d) what you enter in the textboxes are not words but some simple identifying code like a social security number/credit card number/name/etc...

Item (d) is important because you need a more complicated routine if you are enterring words (looking for something like a critical change). The routine I provided looks for an exact match on the entries between the boxes.

Dim x, y, t, tt, z
x = Len(TextBox1.Text)
y = Len(TextBox2.Text)
If x > y Then
t = y / x
Else
t = x / y
End If
If t < 0.8 Then
Msgbox.Show("the text is tooo short")
End If
tt = 1
z = 0
Do Until tt > y
If Mid(TextBox1.Text, tt, 1) = Mid(TextBox2.Text, tt, 1) Then
z = z + 1
End If
tt = tt + 1
Loop
MsgBox.Show(CStr(z / y))

I hope this helps.

Q
 
Last edited by a moderator:
Back
Top