Если не лень читать MSDN: Option Compare { Binary | Text } Parts Binary Optional. Results in string comparisons based on a sort order derived from the internal binary representations of the characters. Text Optional. Results in string comparisons based on a case-insensitive text sort order determined by your system's locale. Remarks If used, the Option Compare statement must appear in a file before any other source statements. The Option Compare statement specifies the string comparison method (Binary or Text) for a class, module or structure. If an Option Compare statement is not included, the default text comparison method is Binary. In Microsoft Windows, sort order is determined by the code page. In the following example, characters are sorted using Option Compare Binary, which produces a typical binary sort order: A < B < E < Z < a < b < e < z < ? < ? < ? < ? < ? < ? When the same characters are sorted using Option Compare Text, the following text sort order is produced: (A=a) < ( ?=?) < (B=b) < (E=e) < (?=?) < (Z=z) < (?=?) Example This example uses the Option Compare statement to set the default string comparison method. The Option Compare statement is used at the module level only. ' Set the string comparison method to Binary. Option Compare Binary ' That is, "AAA" is less than "aaa". ' Set the string comparison method to Text. Option Compare Text ' That is, "AAA" is equal to "aaa". -------------------------------------------------------------------------------- Option Strict { On | Off } Parts On Optional. Enables Option Strict checking. If On or Off is not specified after the Option Strict statement, the default is Off. Off Optional. Disables Option Strict checking. Remarks When used, the Option Strict statement must appear before any other code. Visual Basic .NET generally allows implicit conversions of any data type to any other data type. Data loss can occur when the value of one data type is converted to a data type with less precision or smaller capacity, however, a run-time error message will occur if data will be lost in such a conversion. Option Strict ensures compile-time notification of these types of conversions so they may be avoided. In addition to the conditions described above, Option Strict generates an error for: Any undeclared variable since it is implied that Option Strict also means Option Explicit. Late-binding. Example This example uses the Option Strict statement to show how a declared variable can be converted to a data type of a larger capacity. Attempting to use an undeclared variable causes an error at compile time. Option Strict On ' Force explicit variable declaration. Dim MyVar As Integer ' Declare variables. Dim Obj As Object MyVar = 1000 ' Declared variable does not generate error. MyVar = 1234567890.987654321 ' 'Attempting to convert to an Integer will generate an error. MyInt = 10 ' Undeclared variable generates error in Option Strict mode. Call Obj.Method1() ' Late-bound call generates an error
Ответить
|