Data Types
Data Types
Data types refer to an extensive system used for declaring variables or functions of different
types. The type of a variable determines how much space it occupies in storage and how the bit
pattern stored is interpreted.
https://www.tutorialspoint.com/vb.net/vb.net_data_types.htm# 1/7
6/8/23, 4:29 AM VB.Net - Data Types
Double 8 bytes
-1.79769313486231570E+308 through
-4.94065645841246544E-324, for negative values
4.94065645841246544E-324 through
1.79769313486231570E+308, for positive values
8 bytes on 64-
bit platform
Single 4 bytes
-3.4028235E+38 through -1.401298E-45 for negative
values;
https://www.tutorialspoint.com/vb.net/vb.net_data_types.htm# 2/7
6/8/23, 4:29 AM VB.Net - Data Types
platform
User- Depends on Each member of the structure has a range determined by its
Defined implementing data type and independent of the ranges of the other members
platform
Example
The following example demonstrates use of some of the types −
Live Demo
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 bl Then
'the oath taking
Console.Write(c & " and," & s & vbCrLf)
Console.WriteLine("declaring on the day of: {0}", da)
https://www.tutorialspoint.com/vb.net/vb.net_data_types.htm# 3/7
6/8/23, 4:29 AM VB.Net - Data Types
When the above code is compiled and executed, it produces the following result −
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
https://www.tutorialspoint.com/vb.net/vb.net_data_types.htm# 4/7
6/8/23, 4:29 AM VB.Net - Data Types
1
CBool(expression)
2
CByte(expression)
3
CChar(expression)
4
CDate(expression)
5
CDbl(expression)
6
CDec(expression)
7
CInt(expression)
8
CLng(expression)
9
CObj(expression)
10
CSByte(expression)
11
CShort(expression)
https://www.tutorialspoint.com/vb.net/vb.net_data_types.htm# 5/7
6/8/23, 4:29 AM VB.Net - Data Types
12
CSng(expression)
13
CStr(expression)
14
CUInt(expression)
15
CULng(expression)
16
CUShort(expression)
Example
The following example demonstrates some of these functions −
Live Demo
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()
https://www.tutorialspoint.com/vb.net/vb.net_data_types.htm# 6/7
6/8/23, 4:29 AM VB.Net - Data Types
End Sub
End Module
When the above code is compiled and executed, it produces the following result −
True
-1
True
12/4/2012
1
1
https://www.tutorialspoint.com/vb.net/vb.net_data_types.htm# 7/7