Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted
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?
when the day is bad and life's a curse, cheer up tomorrow may be worse.
Posted (edited)

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

© 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

Edited by quahog
when the day is bad and life's a curse, cheer up tomorrow may be worse.
Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...