Sideway
output.to from Sideway
Draft for Information Only

Content

VB.NET Data Types
  Byte Data Type
  Remarks
  Literal assignments
  Programming tips
  See also
  UShort data type
  Remarks
  Literal assignments
  Programming tips
  See also
  UInteger data type
  Remarks
  Literal assignments
  Programming tips
  See also
  ULong data type
  Remarks
  Literal assignments
  Programming tips
  See also
  Source/Reference

VB.NET Data Types

The supporting VB.NET data types can be divided into

  • Specific forms: String, Object, User-Defined
  • Typical forms: Boolean, Char(2), Date(8), Decimal(16)
  • Unsigned numerics: Byte (1), UShort(2), UInteger(4), ULong(8)
  • Singed numerics:  SByte(1), Short(2), Integer(4), Long(8)
  • Numeric ranges: Single(4), Double(8)

Byte Data Type

Holds unsigned 8-bit (1-byte) integers that range in value from 0 through 255.

Remarks

Use the Byte data type to contain binary data.

The default value of Byte is 0.

Literal assignments

You can declare and initialize a Byte variable by assigning it a decimal literal, a hexadecimal literal, an octal literal, or (starting with Visual Basic 2017) a binary literal. If the integral literal is outside the range of a Byte (that is, if it is less than Byte.MinValue or greater than Byte.MaxValue), a compilation error occurs.

Note

You use the prefix &h or &H to denote a hexadecimal literal, the prefix &b or &B to denote a binary literal, and the prefix &o or &O to denote an octal literal. Decimal literals have no prefix.

Starting with Visual Basic 2017, you can also use the underscore character, _, as a digit separator to enhance readability.

Starting with Visual Basic 15.5, you can also use the underscore character (_) as a leading separator between the prefix and the hexadecimal, binary, or octal digits.

To use the underscore character as a leading separator, you must add the following element to your Visual Basic project (*.vbproj) file:

XML
<PropertyGroup>
  <LangVersion>15.5</LangVersion>
</PropertyGroup>

For more information see setting the Visual Basic language version.

Programming tips

  • Negative Numbers. Because Byte is an unsigned type, it cannot represent a negative number. If you use the unary minus (-) operator on an expression that evaluates to type Byte, Visual Basic converts the expression to Short first.

  • Format Conversions. When Visual Basic reads or writes files, or when it calls DLLs, methods, and properties, it can automatically convert between data formats. Binary data stored in Byte variables and arrays is preserved during such format conversions. You should not use a String variable for binary data, because its contents can be corrupted during conversion between ANSI and Unicode formats.

  • Widening. The Byte data type widens to Short, UShort, Integer, UInteger, Long, ULong, Decimal, Single, or Double. This means you can convert Byte to any of these types without encountering a System.OverflowException error.

  • Type Characters. Byte has no literal type character or identifier type character.

  • Framework Type. The corresponding type in the .NET Framework is the System.Byte structure.

See also

UShort data type

Holds unsigned 16-bit (2-byte) integers ranging in value from 0 through 65,535.

Remarks

Use the UShort data type to contain binary data too large for Byte.

The default value of UShort is 0.

Literal assignments

You can declare and initialize a UShort variable by assigning it a decimal literal, a hexadecimal literal, an octal literal, or (starting with Visual Basic 2017) a binary literal. If the integer literal is outside the range of UShort (that is, if it is less than UInt16.MinValue or greater than UInt16.MaxValue, a compilation error occurs.

Note

You use the prefix &h or &H to denote a hexadecimal literal, the prefix &b or &B to denote a binary literal, and the prefix &o or &O to denote an octal literal. Decimal literals have no prefix.

Starting with Visual Basic 2017, you can also use the underscore character, _, as a digit separator to enhance readability.

Starting with Visual Basic 15.5, you can also use the underscore character (_) as a leading separator between the prefix and the hexadecimal, binary, or octal digits.

To use the underscore character as a leading separator, you must add the following element to your Visual Basic project (*.vbproj) file:

XML
<PropertyGroup>
  <LangVersion>15.5</LangVersion>
</PropertyGroup>

For more information see setting the Visual Basic language version.

Numeric literals can also include the US or us type character to denote the UShort data type.

Programming tips

  • Negative Numbers. Because UShort is an unsigned type, it cannot represent a negative number. If you use the unary minus (-) operator on an expression that evaluates to type UShort, Visual Basic converts the expression to Integer first.

  • CLS Compliance. The UShort data type is not part of the Common Language Specification (CLS), so CLS-compliant code cannot consume a component that uses it.

  • Widening. The UShort data type widens to Integer, UInteger, Long, ULong, Decimal, Single, and Double. This means you can convert UShort to any of these types without encountering a System.OverflowException error.

  • Type Characters. Appending the literal type characters US to a literal forces it to the UShort data type. UShort has no identifier type character.

  • Framework Type. The corresponding type in the .NET Framework is the System.UInt16 structure.

See also

UInteger data type

Holds unsigned 32-bit (4-byte) integers ranging in value from 0 through 4,294,967,295.

Remarks

The UInteger data type provides the largest unsigned value in the most efficient data width.

The default value of UInteger is 0.

Literal assignments

You can declare and initialize a UInteger variable by assigning it a decimal literal, a hexadecimal literal, an octal literal, or (starting with Visual Basic 2017) a binary literal. If the integer literal is outside the range of UInteger (that is, if it is less than UInt32.MinValue or greater than UInt32.MaxValue, a compilation error occurs.

Note

You use the prefix &h or &H to denote a hexadecimal literal, the prefix &b or &B to denote a binary literal, and the prefix &o or &O to denote an octal literal. Decimal literals have no prefix.

Starting with Visual Basic 2017, you can also use the underscore character, _, as a digit separator to enhance readability.

Starting with Visual Basic 15.5, you can also use the underscore character (_) as a leading separator between the prefix and the hexadecimal, binary, or octal digits.

To use the underscore character as a leading separator, you must add the following element to your Visual Basic project (*.vbproj) file:

XML
<PropertyGroup>
  <LangVersion>15.5</LangVersion>
</PropertyGroup>

For more information see setting the Visual Basic language version.

Numeric literals can also include the UI or ui type character to denote the UInteger data type.

Programming tips

The UInteger and Integer data types provide optimal performance on a 32-bit processor, because the smaller integer types (UShort, Short, Byte, and SByte), even though they use fewer bits, take more time to load, store, and fetch.

  • Negative Numbers. Because UInteger is an unsigned type, it cannot represent a negative number. If you use the unary minus (-) operator on an expression that evaluates to type UInteger, Visual Basic converts the expression to Long first.

  • CLS Compliance. The UInteger data type is not part of the Common Language Specification (CLS), so CLS-compliant code cannot consume a component that uses it.

  • Interop Considerations. If you are interfacing with components not written for the .NET Framework, for example Automation or COM objects, keep in mind that types such as uint can have a different data width (16 bits) in other environments. If you are passing a 16-bit argument to such a component, declare it as UShort instead of UInteger in your managed Visual Basic code.

  • Widening. The UInteger data type widens to Long, ULong, Decimal, Single, and Double. This means you can convert UInteger to any of these types without encountering a System.OverflowException error.

  • Type Characters. Appending the literal type characters UI to a literal forces it to the UInteger data type. UInteger has no identifier type character.

  • Framework Type. The corresponding type in the .NET Framework is the System.UInt32 structure.

See also

ULong data type

Holds unsigned 64-bit (8-byte) integers ranging in value from 0 through 18,446,744,073,709,551,615 (more than 1.84 times 10 ^ 19).

Remarks

Use the ULong data type to contain binary data too large for UInteger, or the largest possible unsigned integer values.

The default value of ULong is 0.

Literal assignments

You can declare and initialize a ULong variable by assigning it a decimal literal, a hexadecimal literal, an octal literal, or (starting with Visual Basic 2017) a binary literal. If the integer literal is outside the range of ULong (that is, if it is less than UInt64.MinValue or greater than UInt64.MaxValue, a compilation error occurs.

Note

You use the prefix &h or &H to denote a hexadecimal literal, the prefix &b or &B to denote a binary literal, and the prefix &o or &O to denote an octal literal. Decimal literals have no prefix.

Starting with Visual Basic 2017, you can also use the underscore character, _, as a digit separator to enhance readability.

Starting with Visual Basic 15.5, you can also use the underscore character (_) as a leading separator between the prefix and the hexadecimal, binary, or octal digits.

To use the underscore character as a leading separator, you must add the following element to your Visual Basic project (*.vbproj) file:

XML
<PropertyGroup>
  <LangVersion>15.5</LangVersion>
</PropertyGroup>

For more information see setting the Visual Basic language version.

Numeric literals can also include the UL or ul type character to denote the ULong data type.

Programming tips

  • Negative Numbers. Because ULong is an unsigned type, it cannot represent a negative number. If you use the unary minus (-) operator on an expression that evaluates to type ULong, Visual Basic converts the expression to Decimal first.

  • CLS Compliance. The ULong data type is not part of the Common Language Specification (CLS), so CLS-compliant code cannot consume a component that uses it.

  • Interop Considerations. If you are interfacing with components not written for the .NET Framework, for example Automation or COM objects, keep in mind that types such as ulong can have a different data width (32 bits) in other environments. If you are passing a 32-bit argument to such a component, declare it as UInteger instead of ULong in your managed Visual Basic code.

    Furthermore, Automation does not support 64-bit integers on Windows 95, Windows 98, Windows ME, or Windows 2000. You cannot pass a Visual Basic ULong argument to an Automation component on these platforms.

  • Widening. The ULong data type widens to Decimal, Single, and Double. This means you can convert ULong to any of these types without encountering a System.OverflowException error.

  • Type Characters. Appending the literal type characters UL to a literal forces it to the ULong data type. ULong has no identifier type character.

  • Framework Type. The corresponding type in the .NET Framework is the System.UInt64 structure.

See also

Source/Reference


©sideway

ID: 200700027 Last Updated: 27/7/2020 Revision: 0 Ref:

close

References

  1. Active Server Pages,  , http://msdn.microsoft.com/en-us/library/aa286483.aspx
  2. ASP Overview,  , http://msdn.microsoft.com/en-us/library/ms524929%28v=vs.90%29.aspx
  3. ASP Best Practices,  , http://technet.microsoft.com/en-us/library/cc939157.aspx
  4. ASP Built-in Objects,  , http://msdn.microsoft.com/en-us/library/ie/ms524716(v=vs.90).aspx
  5. Response Object,  , http://msdn.microsoft.com/en-us/library/ms525405(v=vs.90).aspx
  6. Request Object,  , http://msdn.microsoft.com/en-us/library/ms524948(v=vs.90).aspx
  7. Server Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525541(v=vs.90).aspx
  8. Application Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525360(v=vs.90).aspx
  9. Session Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms524319(8v=vs.90).aspx
  10. ASPError Object,  , http://msdn.microsoft.com/en-us/library/ms524942(v=vs.90).aspx
  11. ObjectContext Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525667(v=vs.90).aspx
  12. Debugging Global.asa Files,  , http://msdn.microsoft.com/en-us/library/aa291249(v=vs.71).aspx
  13. How to: Debug Global.asa files,  , http://msdn.microsoft.com/en-us/library/ms241868(v=vs.80).aspx
  14. Calling COM Components from ASP Pages,  , http://msdn.microsoft.com/en-us/library/ms524620(v=VS.90).aspx
  15. IIS ASP Scripting Reference,  , http://msdn.microsoft.com/en-us/library/ms524664(v=vs.90).aspx
  16. ASP Keywords,  , http://msdn.microsoft.com/en-us/library/ms524672(v=vs.90).aspx
  17. Creating Simple ASP Pages,  , http://msdn.microsoft.com/en-us/library/ms524741(v=vs.90).aspx
  18. Including Files in ASP Applications,  , http://msdn.microsoft.com/en-us/library/ms524876(v=vs.90).aspx
  19. ASP Overview,  , http://msdn.microsoft.com/en-us/library/ms524929(v=vs.90).aspx
  20. FileSystemObject Object,  , http://msdn.microsoft.com/en-us/library/z9ty6h50(v=vs.84).aspx
  21. http://msdn.microsoft.com/en-us/library/windows/desktop/ms675944(v=vs.85).aspx,  , ADO Object Model
  22. ADO Fundamentals,  , http://msdn.microsoft.com/en-us/library/windows/desktop/ms680928(v=vs.85).aspx
close
IMAGE

Home 5

Business

Management

HBR 3

Information

Recreation

Hobbies 8

Culture

Chinese 1097

English 337

Reference 67

Computer

Hardware 149

Software

Application 198

Digitization 119

Numeric 19

Programming

Web 283

Unicode 494

HTML 65

CSS 58

ASP.NET 97

OS 389

DeskTop 7

Python 19

Knowledge

Mathematics

Formulas 8

Algebra 25

Number Theory 206

Trigonometry 18

Geometry 18

Calculus 67

Complex Analysis 21

Engineering

Tables 8

Mechanical

Mechanics 1

Rigid Bodies

Statics 92

Dynamics 37

Fluid 5

Fluid Kinematics 5

Control

Process Control 1

Acoustics 19

FiniteElement 2

Physics

Electric 27

Biology 1

Geography 1


Copyright © 2000-2020 Sideway . All rights reserved Disclaimers last modified on 06 September 2019