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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compare 2 text fields

Status
Not open for further replies.

leckie

Programmer
Apr 19, 2001
65
0
0
GB
I have to text fields: field1 has "2102" and field2 has "2201".

Although the numbers are different they both contain the correct digits i.e. 2 x 2s, 1 x 0 and 1 x 1.

what i would like to do is compare the 2 fields: for example if field1 had "2201" and field2 had "4022", field2 would be short of a digit "1" and surplus of a digit "4"

to explain why I need to do this: Field1 is a typed in house no, field2 is numerals that have been ordered

any help much appreciated
 
this would be quite complicated, since I can't think of anything built in that'll even come close...

1) first, you need to seperate each character in the 2 strings
I think there's something built in for this, but can't remember it exactly, F1/F2 to find the function...

2) then cast all the characters to integers (not strictly nessecary)

3) then for every character in str2, check to see if it's in str1, and label accordingly...
either use 2 nested loops, or the IN operator...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top