Home > Software engineering >  String comparison function StrComp problem, consult
String comparison function StrComp problem, consult

Time:10-17

Winxp:
Changfeng StrComp (" 2013 ", "Chrysler", vbTextCompare)=1

Windows 7:
Changfeng StrComp (" 2013 ", "Chrysler", vbTextCompare)=1

Vb code by comparing database list sorted out two keywords, sort is inconsistent with database under Windows 7

Please answer

CodePudding user response:

Try:
N=StrComp (StrConv (" 2013 "changfeng, vbUnicode), StrConv (" Chrysler", vbUnicode), vbTextCompare)

CodePudding user response:

Converted to Unicode again, also have problems

? Changfeng StrComp (" 2013 ", "Chrysler", vbTextCompare)
1
? StrComp (StrConv (" 2013 "changfeng, vbUnicode), StrConv (" Chrysler", vbUnicode), vbTextCompare)
1

? StrComp (" Beijing operations center ", "electric car division," vbTextCompare)
1
? StrComp (StrConv (" Beijing operations center ", vbUnicode), StrConv (" electric car division, "vbUnicode), vbTextCompare)
1

CodePudding user response:

Is converted to Unicode, XP and Windows 7 results are consistent on the two machines?

You compare before and after the transformation of the results is meaningless, before and after the transformation result may be different, or turn it?

StrComp is based on the system used in the default code page sorting, if two machines all the default code page is different, the results might be different, you can also through the third parameter is set the code page to try,

CodePudding user response:

After tried several, is converted to Unicode, XP and Windows 7 on the two machines is consistent with the result of the

Through database sorting, "Beijing operations center" & lt; "Electric group
"
StrComp (StrConv (" Beijing operations center ", vbUnicode), StrConv (" electric car division, "vbUnicode), vbTextCompare)=1

Comparison of results and inconsistencies in the database, the code loop compare two sorted lists to judge, can not get the expected results,

CodePudding user response:

That's your database is not sorted by Unicode,

There are many Chinese characters coding scheme, the same Chinese characters, with different coding coding scheme is different,

If you can not find the ranking method of unified, you can query the database to determine their order,

CodePudding user response:

Of course, you can also put the string into a Unicode, after again write database, that is consistent,