Contents
Index 🔎︎

# StrComp Function

Compares two strings and returns an integer value that represents the result of the comparison.

### Syntax:

    StrComp (string1 As String, string2 As String[, Compare As Integer]) As Integer

### Parameters:

string1: Any string expression

string2: Any string expression

Compare: This optional parameter sets the comparison method. If Compare = 1, the string comparison is case-sensitive. If Compare = 0, no distinction is made between uppercase and lowercase letters.

### Return value:

Integer

- If string1 < string2 the function returns -1

- If string1 = string2 the function returns 0

- If string1 > string2 the function returns 1

### Error codes:

D'oh! You found a bug (text/sbasic/shared/00000003.xhp#err5 not found).

### Example:

    Sub ExampleStrComp
    Dim iVar As Single
    Dim sVar As String
        iVar = 123.123
        sVar = Str$(iVar)
        MsgBox strcomp(sVar , Str$(iVar),1)
    End Sub