This documentation is archived and is not being maintained.

6.2.3 Option Compare Statement

Visual Studio .NET 2003

The Option Compare statement determines the semantics of string comparisons. String comparisons are carried out either using binary comparisons (in which the binary Unicode value of each character is compared) or text comparisons (in which the lexical meaning of each character is compared using the current culture). If no statement is specified in a file, the compilation environment controls which type of comparison will be used.

Note   Compare, Binary, and Text are not reserved words.
Option Compare Text

Imports System

Module M
    Sub Main()
        Console.WriteLine("a" = "A")    ' Prints True.
    End Sub
End Module

In this case, the string comparison is done using a text comparison that ignores case differences. If Option Compare Binary had been specified, then this would have printed False.

OptionCompareStatement ::= Option Compare CompareOption LineTerminator
CompareOption ::= Binary | Text

See Also

6.2.1 Option Explicit Statement | 6.2.2 Option Strict Statement | 6.2.4 Integer Overflow Checks | 6.2 Compilation Options | 11.15 Like Operator | Option Compare Statement (Visual Basic Language Reference)