Microsoft Visual Basic .NET or Microsoft Visual Basic 2005 parser incorrectly evaluates the data type if the minimum value of the numeric data types is parsed (811402)
The information in this article applies to:
- Microsoft Visual Basic 2005
- Microsoft Visual Basic .NET (2003)
- Microsoft Visual Basic .NET (2002)
SYMPTOMSIf the minimum value of the numeric data types is parsed,
the Microsoft Visual Basic .NET or Microsoft Visual Basic 2005 parser incorrectly evaluates the data type. For
example, if you use an Integer data type, the Visual Basic .NET or Visual Basic 2005 parser incorrectly evaluates
-(2^31) as Long rather than Integer. However, the Microsoft Visual C# .NET or Microsoft Visual C# 2005 parser appropriately
evaluates the data type.CAUSEThis behavior occurs because both Visual Basic .NET (or Visual Basic 2005) and
Visual C# have syntactic grammar that does not include the leading hyphen
(-) as part of the numeric literal. Therefore,
-(2^31) is parsed as
2^31, and
2^31 is Long.
Visual C# .NET or Visual C# 2005 has a special rule to handle the hyphen
prefix for numbers. Visual Basic .NET or Visual Basic 2005 does not contain any special handling to
make its behavior consistent with Microsoft Visual Basic 6.0.WORKAROUNDTo work around this behavior, complete one of the following
steps:
- Use the MinValue property of the numeric data type. For example, use Integer.MinValue.
- Use numeric expression that evaluates to the minimum value.
For example, rather than -2147483648, use
-2147483647
-1.
STATUS This
behavior is by design.
Modification Type: | Minor | Last Reviewed: | 10/3/2006 |
---|
Keywords: | kbvs2005swept kbvs2005applies kbCompiler kbprb KB811402 kbAudDeveloper |
---|
|