Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language:
Expertise: Beginner
Aug 6, 1997

Choose Compares Carefully

A straight ASCII compare, such as 'F "A" < "B" THEN' is much faster then using VB's StrComp("A", "B", 1). However, when you use this test to sort an array of strings, your result will not be "internationally" correct. Using an ASCII compare simply tests the string for which the ASCII values of one character come before those of another. The StrComp() function uses the current code page setting in Windows to determine which characters alphabetize before others based on the current country setting. Using the StrComp() when sorting and displaying output to your user will make your application much more internationally friendly. If you are sorting and testing for internal purposes, an ASCII compare is much faster. Make sure you are consistent with the compares or your results might not be what you expect. Don't do a binary chop against an alphabetized array using an ASCII compare or vice versa. On the same note, using UCase$() (or LCase$()) is very fast. However, these functions only zip through a string, setting or clearing the fifth bit of characters "A-Z," "a-z." To adjust case properly for international character sets, use StrConv(string$, vbUpperCase|vbLowerCase). Once again, for your own code's internal use, use UCase$()/LCase$() because they are faster, but for display purposes use StrConv(). During testing of UCase$() .versus StrConv(), both returned the same results under VB4. However, since StrConv() provides other services you may need (or in case this was simply a Microsoft bug), you should still use StrConv() in place of UCase$()/LCase$().
MicroHelp Uninstaller
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date