May 13, 2021 vb.net
A data type is an extended system that declares different types of variables or functions. T he type of variable determines how much space it takes up in storage and how it interprets the stored bit pattern.
Vb. N et offers a variety of data types. A ll data types shown in the following table are available:
The data type | Storage allocation | The range of values |
---|---|---|
Boolean | Depends on the implementation platform | True or false |
Byte | 1 byte | 0 to 255 (unsigned) |
Char | 2 bytes | 0 to 65535 (unsigned) |
Date | 8 bytes | 00:00:00 (midnight) from 11:31 to 11:59:59 on 31 December 0001 |
Decimal | 16 bytes | 0 to 79,228,162,514,264,337,593,543,950,335 (-/- 7.9 ... E plus 28), no number of points; 0 to 7.92281625142643375935439550335, where there are 28 bits to the right of the dodge point |
Double | 8 bytes |
-1.79769313486231570E , 308 to -4.94065645841246544E-324, negative values 4.94065645841246544E-324 to 1.79769313486231570E and 308, for positive values
|
Integer | 4 bytes | -2,147,483,648 to 2,147,483,647 (symbol) |
Long | 8 bytes | -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 (signature) |
Object |
4 bytes on a 32-bit platform 8 bytes on a 64-bit platform |
Any type can be stored in a variable of the Object type |
SByte | 1 byte | -128 to 127 (signature) |
Short | 2 bytes | -32,768 to 32,767 (signature) |
Single | 4 bytes |
-3.4028235E plus 38 to -1.401298E-45 is negative; 1.401298E-45 to 3.4028235E plus 38 positive |
String | Depends on the implementation platform | 0 to about 2 billion Unicode characters |
UInteger | 4 bytes | 0 to 4294967295 (unsigned) |
ULONG | 8 bytes | 0 to 18,446,744,073,709,551,615 (signature) |
User-Defined | Depends on the implementation platform | Each member of the structure has a range determined by its data type and is independent of the scope of the other members |
UShort | 2 bytes | 0 to 65,535 (unsigned) |
The
following
example
shows
some
of
the
types that
use
Module DataTypes Sub Main() Dim b As Byte Dim n As Integer Dim si As Single Dim d As Double Dim da As Date Dim c As Char Dim s As String Dim bl As Boolean b = 1 n = 1234567 si = 0.12345678901234566 d = 0.12345678901234566 da = Today c = "U"c s = "Me" If ScriptEngine = "VB" Then bl = True Else bl = False End If If bl Then 'the oath taking Console.Write(c & " and," & s & vbCrLf) Console.WriteLine("declaring on the day of: {0}", da) Console.WriteLine("We will learn VB.Net seriously") Console.WriteLine("Lets see what happens to the floating point variables:") Console.WriteLine("The Single: {0}, The Double: {1}", si, d) End If Console.ReadKey() End Sub End Module
When the above code is compiled and executed, it produces the following results:
U and, Me declaring on the day of: 12/4/2012 12:00:00 PM We will learn VB.Net seriously Lets see what happens to the floating point variables: The Single:0.1234568, The Double: 0.123456789012346
Vb. N et provides the following inline type conversion functions:
SN | Features and instructions |
---|---|
1 |
CBool (Expression) Convert the expression to a Boolean data type. |
2 |
CByte (Expression) Convert the expression to a byte data type. |
3 |
CChar (Expression) Convert the expression to a Char data type. |
4 |
CD ate (expression) Convert the expression to a Date data type |
5 |
CDbl (Expression) Convert an expression to a double data type. |
6 |
CDec (Expression) Convert an expression to a hedding data type. |
7 |
CInT (Expression) Convert an expression to an integer data type. |
8 |
CLng function (expression) Convert an expression to a long data type. |
9 |
CObj (Expression) Convert an expression to an object type. |
10 |
CSByte (Expression) Convert the expression to a SByte data type. |
11 |
CShort (Expression) Convert an expression to a short data type. |
12 |
CSng function (expression) Convert an expression to a single data type. |
13 |
CStr's (expression) Converts an expression to a string data type. |
14 |
CUInt (Expression) Convert the expression to a UInt data type. |
15 |
CULng (Expression) Convert the expression to a ULng data type. |
16 |
CUShort (Expression) Convert the expression to a UShort data type. |
The following example demonstrates some of these features:
Module DataTypes Sub Main() Dim n As Integer Dim da As Date Dim bl As Boolean = True n = 1234567 da = Today Console.WriteLine(bl) Console.WriteLine(CSByte(bl)) Console.WriteLine(CStr(bl)) Console.WriteLine(CStr(da)) Console.WriteLine(CChar(CChar(CStr(n)))) Console.WriteLine(CChar(CStr(da))) Console.ReadKey() End Sub End Module
When the above code is compiled and executed, it produces the following results:
True -1 True 12/4/2012 1 1