Windows API Guide: JOYINFO Structure


Declare Function lstrcmpi Lib "kernel32.dll" Alias "lstrcmpiA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long

Platforms

  • Windows 95: Supported.
  • Windows 98: Supported.
  • Windows NT: Requires Windows NT 3.1 or later.
  • Windows 2000: Supported.
  • Windows CE: Not Supported.

Description & Usage

lstrcmpi compares two strings using a case-insensitive comparison based on the current user locale. The function uses a word sort method, which places all symbols except hyphens and apostrophes before the letter "a" (hyphens and apostrophes are treated differently). The strings are compared by comparing the first character of each string, then the second character, etc., until unequal characters are encountered.

Return Value

If the function returns a negative value, the first string is less than the second string (i.e., the first string comes before the second string in alphabetical order). If the function returns 0, the two strings are equal. If the function returns a positive value, the first string is greater than the second string. In any case, the actual return value is the difference of the first unequal characters encountered.

Visual Basic-Specific Issues

None.

Parameters

lpString1
The first string to compare.
lpString2
The second string to compare.

Example

' This code is licensed according to the terms and conditions listed here. ' Use a case-insenitive comparison method to alphabetically sort ' nine words.  The sorting method simply compares each possible pair ' of words; if a pair is out of alphabetical order, they are switched. ' (Note how this sort will seemingly arrange the "Denver" trio in ' a random order, depending on how the search loops play out -- ' the three strings are equal in the eyes of the function and therefore ' not sorted relative to each other.) Dim words(1 To 9) As String  ' the words to sort Dim tempstr As String  ' buffer used to swap strings Dim oc As Integer, ic As Integer  ' counter variables Dim compval As Long  ' result of comparison ' Load the nine strings into the array. words(1) = "can't" words(2) = "cant" words(3) = "cannot" words(4) = "pants" words(5) = "co-op" words(6) = "coop" words(7) = "Denver" words(8) = "denver" words(9) = "denveR" ' Sort the strings, swapping any pairs which are out of order. For oc = 1 To 8  ' first string of the pair   For ic = oc + 1 To 9  ' second string of the pair     ' Compare the two strings.     compval = lstrcmpi(words(oc), words(ic))     ' If words(oc) is greater, swap them.     If compval> 0 Then       tempstr = words(oc)       words(oc) = words(ic)       words(ic) = tempstr     End If   Next ic Next oc ' Display the list of sorted words. For oc = 1 To 9   Debug.Print words(oc) Next oc

See Also

CompareString, lstrcmp

Category

Strings

Go back to the alphabetical Function listing.
Go back to the Reference section index.


Last Modified: December 30, 1999
This page is copyright © 1999 Paul Kuliniewicz. Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/l/lstrcmpi.html



Windows API Guide
Windows API Guide - Reference - Volume 1: Version 3.0 For the MS-DOS and PC-DOS Operating Systems
ISBN: B001V0KQIY
EAN: N/A
Year: 1998
Pages: 610

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net