SlideShare a Scribd company logo
VB.NET:- Basic Syntax
BCA -501
2
Content
 Basic Syntax
 Keywords
 Identifiers
 Comments
 Data Type
 Type Conversion
3
Basic Syntax
VB.Net is an object-oriented programming language. In Object-Oriented Programming methodology,
a program consists of various objects that interact with each other by means of actions. The actions
that an object may take are called methods. Objects of the same kind are said to have the same type
or, more often, are said to be in the same class.
When we consider a VB.Net program, it can be defined as a collection of objects that communicate
via invoking each other's methods. Let us now briefly look into what do class, object, methods and
instance variables mean.
Object − Objects have states and behaviors. Example: A dog has states - color, name, breed as well
as behaviors - wagging, barking, eating, etc. An object is an instance of a class.
Class − A class can be defined as a template/blueprint that describes the behaviors/states that
objects of its type support.
Methods − A method is basically a behavior. A class can contain many methods. It is in methods
where the logics are written, data is manipulated and all the actions are executed.
Instance Variables − Each object has its unique set of instance variables. An object's state is
created by the values assigned to these instance variables.
4
Keywords
 A keyword is a reserved word with special meanings in the compiler, whose
meaning cannot be changed.
 Therefore, these keywords cannot be used as an identifier in VB.NET programming
such as class name, variable, function, module, etc.
 Example : AddHandler, AddressOf, Alias, And, As, Boolean, ByRef, Byte, ByVal,
Call, Case, Catch, Const , Continue, Dim, Do, Double, Each, Else, ElseIf, End, etc.
5
Identifiers
 An identifier is a name used to identify a class, variable, function, or any other user-defined item.
 There are various rules for identifier in VB.NET, as follows:
1. The first character of an identifier must start with an alphabet or underscore, that could be
followed by any sequence of digits (0-9), letter or underscore.
2. An identifier should not contain any reserved keyword.
3. It should not start with any digit.
4. It should not more than 51 characters.
5. An identifier can contain two underscores, but should not be consecutive.
6. It should not include any commas or white spaces in-between characters.
Some invalid identifiers are:
5be : First character should be alphabets or underscore (_)
Class, Shared : Keyword are not allowed as identifier name.
A# - : Identifier does not contain any special symbol.
Avg marks : It should not contain any blank space.
Some valid identifiers are:
Value, a, rec1, my_data, Marks, num, etc
6
Comments
 A comment is used to explain the various steps that we have taken in our programming. The
compiler ignores these comment statements because the compiler is not executed or processed
in VB.NET. Therefore, it does not take any place in your compilation code.
 In VB.NET, we use ( ' ) symbol to comment a statement.
Module Module1
Sub Main()
'Here Console.WriteLine() is used to print a statement.
Console.WriteLine(" Welcome to world of .NET Programming")
'Above statement displays Welcome to world of .NET Programming
End Sub
End Module
7
VB.NET Data Type
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.
In VB.NET, data type is used to define the type of a variable or function in a program.
It also provide functionality for the conversion of one data type to another type using the data
conversion function.
For example, when we declare a variable, we have to tell the compiler what type of data or value is
allocated to different kinds of variables to hold different amounts of space in computer memory.
Syntax:
Dim Variable_Name as DataType
VariableName: It defines the name of the variable that you assign to store values.
DataType: It represents the name of the data type that you assign to a variable.
8
VB.NET Data Type
Data Types Required Space Value Range
Boolean A Boolean type depends on
the implementing platform
True or False
Byte 1 byte Byte Range start from 0 to 255 (unsigned)
Char 2 bytes Char Range start from 0 to 65535 (unsigned)
Date 8 bytes Date range can be 0:00:0 (midnight) January 1, 0001 to
11:5959 PM of December 31, 9999.
Decimal 16 bytes Range from 0 to +/-
79,228,162,514,264,337,593,543,950,335
(+/-7.9…E+28) without any decimal point;
And 0 to +/-7.92281625142264337593543950335 with
28 position to the right of the decimal
Double 8 bytes -1.79769313486231570E+308 to -4.94-
65645841246544E-324 for negative values;
4.94065645841246544E-324 to
1.79769313486231570E+308, for positive values
Integer 4 bytes -2,147,483,648 to 2,147,483,647 (signed)
Long 8 bytes -9,223,372,036,854,775,808 to
9,223,372,036,854,775,807 (9.2…E + 18) (signed)
9
VB.NET Data Type Cont…
Data Types Required Space Value Range
Object Object size based on the
platform such as 4 bytes in
32-bit and 8 bytes in 64-bit
platform
It can store any type of data defined in a variable of
type Object
SByte 1 byte -128 to 127 (signed)
Short 2 bytes -32,768 to 32,767 (signed)
Single 4 bytes -3.4028235E + 38 to -1.401298E-45 for negative
values;
And for positive value: 1.401298E-45 to 3.4028235E
+ 38.
String String Datatype depend on
the implementing platform
It accepts Unicode character from 0 to approximately
2 billion characters.
UInteger 4 bytes The range start from 0 to 4,294,967,295 (unsigned)
ULong 8 bytes The range of ULong start from 0 to
18,446,744,073,709,551,615 (1.8…E + 19)
(unsigned)
User-
Defined
(structure)
A user-defined data type
depends on the
implementing platform
Each member of the structure has its own data type
and limits independent of the other members' ranges.
UShort 2 bytes Range from 0 to 65,535 (unsigned)
10
Example of Data Type
Module Module1
Sub Main()
Dim b As Byte = 1
Dim num As Integer = 5
Dim si As Single
Dim db As Double
Dim get_date As Date
Dim c As Char
Dim str As String
b = 1
num = 20
si = 0.12
db = 2131.787
get_date = Today
c = "A"
str = "Hello Friends..."
Console.WriteLine("Welcome to the DataType Demonstration")
Console.WriteLine("Byte is: {0}", b)
Console.WriteLine("Integer number is: {0}", num)
Console.WriteLine("Single data type is: {0}", si)
Console.WriteLine("Double data type is: {0}", db)
Console.WriteLine("Today is: {0}", get_date)
Console.WriteLine("Character is: {0}", b)
Console.WriteLine("String message is: {0}", str)
Console.ReadKey()
End Sub
End Module
11
Type Conversion Functions
VB.Net provides the following in-line type conversion functions −
1. CBool(expression): It is used to convert an expression into a Boolean data type.
2. CByte(expression): It is used to convert an expression to a Byte data type.
3. CChar(expression): It is used to convert an expression to a Char data type.
4. CDate(expression): It is used to convert an expression to a Date data type.
5. CDbl(expression): It is used to convert an expression into a Double data type.
6. CDec(expression): It is used to convert an expression into a Decimal data type.
7. CInt(expression): It is used to convert an expression to an Integer data type.
8. CLng(expression): It is used to convert an expression to a Long data type.
9. CObj(expression): It is used to convert an expression to an Object data type.
10. CSByte(expression): It is used to convert an expression to an SByte data type.
11. CShort(expression): It is used to convert an expression to a Short data type.
12. CSng(expression): It is used to convert an expression into a Single data type.
13. CStr(expression): It is used to convert an expression into a String data type.
14. CUInt(expression): It is used to convert an expression to a UInt data type.
15. CULng(expression): It is used to convert an expression to a ULng data type.
16. CUShort(expression): It is used to convert an expression into a UShort data type.
12
Example of Type Conversion
Module Module1
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

More Related Content

What's hot

Lecture 1 introduction to vb.net
Lecture 1   introduction to vb.netLecture 1   introduction to vb.net
Lecture 1 introduction to vb.net
MUKALU STEVEN
 
Dbms relational model
Dbms relational modelDbms relational model
Dbms relational model
Chirag vasava
 
structured programming
structured programmingstructured programming
structured programming
Ahmad54321
 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp Presentation
Vishwa Mohan
 
Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
Prateek Parimal
 
Relational model
Relational modelRelational model
Relational model
Dabbal Singh Mahara
 
Introduction to vb.net
Introduction to vb.netIntroduction to vb.net
Introduction to vb.net
Jaya Kumari
 
STRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIESSTRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIES
VENNILAV6
 
Programming in c#
Programming in c#Programming in c#
Programming in c#
Shehrevar Davierwala
 
Entity Relationship Diagrams
Entity Relationship DiagramsEntity Relationship Diagrams
Entity Relationship Diagrams
sadique_ghitm
 
VB.net
VB.netVB.net
VB.net
PallaviKadam
 
Java: GUI
Java: GUIJava: GUI
Java: GUI
Tareq Hasan
 
C tokens
C tokensC tokens
C tokens
Manu1325
 
3 Tier Architecture
3  Tier Architecture3  Tier Architecture
3 Tier Architecture
Webx
 
ER-Model-ER Diagram
ER-Model-ER DiagramER-Model-ER Diagram
ER-Model-ER Diagram
Saranya Natarajan
 
Osi reference model
Osi reference modelOsi reference model
Osi reference model
vasanthimuniasamy
 
Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship Diagram
Shakila Mahjabin
 
Components of .NET Framework
Components of .NET FrameworkComponents of .NET Framework
Components of .NET Framework
Roshith S Pai
 
Generalization and specialization
Generalization and specializationGeneralization and specialization
Generalization and specialization
Knowledge Center Computer
 
Architecture of operating system
Architecture of operating systemArchitecture of operating system
Architecture of operating system
Supriya Kumari
 

What's hot (20)

Lecture 1 introduction to vb.net
Lecture 1   introduction to vb.netLecture 1   introduction to vb.net
Lecture 1 introduction to vb.net
 
Dbms relational model
Dbms relational modelDbms relational model
Dbms relational model
 
structured programming
structured programmingstructured programming
structured programming
 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp Presentation
 
Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
 
Relational model
Relational modelRelational model
Relational model
 
Introduction to vb.net
Introduction to vb.netIntroduction to vb.net
Introduction to vb.net
 
STRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIESSTRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIES
 
Programming in c#
Programming in c#Programming in c#
Programming in c#
 
Entity Relationship Diagrams
Entity Relationship DiagramsEntity Relationship Diagrams
Entity Relationship Diagrams
 
VB.net
VB.netVB.net
VB.net
 
Java: GUI
Java: GUIJava: GUI
Java: GUI
 
C tokens
C tokensC tokens
C tokens
 
3 Tier Architecture
3  Tier Architecture3  Tier Architecture
3 Tier Architecture
 
ER-Model-ER Diagram
ER-Model-ER DiagramER-Model-ER Diagram
ER-Model-ER Diagram
 
Osi reference model
Osi reference modelOsi reference model
Osi reference model
 
Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship Diagram
 
Components of .NET Framework
Components of .NET FrameworkComponents of .NET Framework
Components of .NET Framework
 
Generalization and specialization
Generalization and specializationGeneralization and specialization
Generalization and specialization
 
Architecture of operating system
Architecture of operating systemArchitecture of operating system
Architecture of operating system
 

Similar to Keywords, identifiers and data type of vb.net

Chapter 2 c#
Chapter 2 c#Chapter 2 c#
Chapter 2 c#
megersaoljira
 
Unit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programmingUnit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programming
Abha Damani
 
2 programming with c# i
2 programming with c# i2 programming with c# i
2 programming with c# i
siragezeynu
 
C#
C#C#
Data types
Data typesData types
Data types
Sachin Satwaskar
 
Dot net programming concept
Dot net  programming conceptDot net  programming concept
Dot net programming concept
sandeshjadhav28
 
unit 1 (1).pptx
unit 1 (1).pptxunit 1 (1).pptx
unit 1 (1).pptx
PriyadarshiniS28
 
C++ data types
C++ data typesC++ data types
C++ data types
pratikborsadiya
 
2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)
Shoaib Ghachi
 
E learning excel vba programming lesson 3
E learning excel vba programming  lesson 3E learning excel vba programming  lesson 3
E learning excel vba programming lesson 3
Vijay Perepa
 
Structured Languages
Structured LanguagesStructured Languages
Structured Languages
Mufaddal Nullwala
 
Concept Of C++ Data Types
Concept Of C++ Data TypesConcept Of C++ Data Types
Concept Of C++ Data Types
k v
 
Java - Basic Datatypes.pptx
Java - Basic Datatypes.pptxJava - Basic Datatypes.pptx
Java - Basic Datatypes.pptx
Nagaraju Pamarthi
 
Bca5020 visual programming
Bca5020  visual programmingBca5020  visual programming
Bca5020 visual programming
smumbahelp
 
Bca5020 visual programming
Bca5020  visual programmingBca5020  visual programming
Bca5020 visual programming
smumbahelp
 
Core C# Programming Constructs, Part 1
Core C# Programming Constructs, Part 1Core C# Programming Constructs, Part 1
Core C# Programming Constructs, Part 1
Vahid Farahmandian
 
C Sharp Nagina (1)
C Sharp Nagina (1)C Sharp Nagina (1)
C Sharp Nagina (1)
guest58c84c
 
C Sharp Jn (1)
C Sharp Jn (1)C Sharp Jn (1)
C Sharp Jn (1)
jahanullah
 
Data Handling
Data HandlingData Handling
Data Handling
Praveen M Jigajinni
 
Concept of c data types
Concept of c data typesConcept of c data types
Concept of c data types
Manisha Keim
 

Similar to Keywords, identifiers and data type of vb.net (20)

Chapter 2 c#
Chapter 2 c#Chapter 2 c#
Chapter 2 c#
 
Unit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programmingUnit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programming
 
2 programming with c# i
2 programming with c# i2 programming with c# i
2 programming with c# i
 
C#
C#C#
C#
 
Data types
Data typesData types
Data types
 
Dot net programming concept
Dot net  programming conceptDot net  programming concept
Dot net programming concept
 
unit 1 (1).pptx
unit 1 (1).pptxunit 1 (1).pptx
unit 1 (1).pptx
 
C++ data types
C++ data typesC++ data types
C++ data types
 
2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)
 
E learning excel vba programming lesson 3
E learning excel vba programming  lesson 3E learning excel vba programming  lesson 3
E learning excel vba programming lesson 3
 
Structured Languages
Structured LanguagesStructured Languages
Structured Languages
 
Concept Of C++ Data Types
Concept Of C++ Data TypesConcept Of C++ Data Types
Concept Of C++ Data Types
 
Java - Basic Datatypes.pptx
Java - Basic Datatypes.pptxJava - Basic Datatypes.pptx
Java - Basic Datatypes.pptx
 
Bca5020 visual programming
Bca5020  visual programmingBca5020  visual programming
Bca5020 visual programming
 
Bca5020 visual programming
Bca5020  visual programmingBca5020  visual programming
Bca5020 visual programming
 
Core C# Programming Constructs, Part 1
Core C# Programming Constructs, Part 1Core C# Programming Constructs, Part 1
Core C# Programming Constructs, Part 1
 
C Sharp Nagina (1)
C Sharp Nagina (1)C Sharp Nagina (1)
C Sharp Nagina (1)
 
C Sharp Jn (1)
C Sharp Jn (1)C Sharp Jn (1)
C Sharp Jn (1)
 
Data Handling
Data HandlingData Handling
Data Handling
 
Concept of c data types
Concept of c data typesConcept of c data types
Concept of c data types
 

More from Jaya Kumari

Python data type
Python data typePython data type
Python data type
Jaya Kumari
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
Jaya Kumari
 
Variables in python
Variables in pythonVariables in python
Variables in python
Jaya Kumari
 
Basic syntax supported by python
Basic syntax supported by pythonBasic syntax supported by python
Basic syntax supported by python
Jaya Kumari
 
Oops
OopsOops
Inheritance
InheritanceInheritance
Inheritance
Jaya Kumari
 
Overloading
OverloadingOverloading
Overloading
Jaya Kumari
 
Decision statements
Decision statementsDecision statements
Decision statements
Jaya Kumari
 
Loop control statements
Loop control statementsLoop control statements
Loop control statements
Jaya Kumari
 
Looping statements
Looping statementsLooping statements
Looping statements
Jaya Kumari
 
Operators used in vb.net
Operators used in vb.netOperators used in vb.net
Operators used in vb.net
Jaya Kumari
 
Frame class library and namespace
Frame class library and namespaceFrame class library and namespace
Frame class library and namespace
Jaya Kumari
 
Introduction to .net
Introduction to .net Introduction to .net
Introduction to .net
Jaya Kumari
 
Jsp basic
Jsp basicJsp basic
Jsp basic
Jaya Kumari
 
Java script Basic
Java script BasicJava script Basic
Java script Basic
Jaya Kumari
 
Sgml and xml
Sgml and xmlSgml and xml
Sgml and xml
Jaya Kumari
 
Java script Advance
Java script   AdvanceJava script   Advance
Java script Advance
Jaya Kumari
 
Html form
Html formHtml form
Html form
Jaya Kumari
 
Html Concept
Html ConceptHtml Concept
Html Concept
Jaya Kumari
 

More from Jaya Kumari (19)

Python data type
Python data typePython data type
Python data type
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Variables in python
Variables in pythonVariables in python
Variables in python
 
Basic syntax supported by python
Basic syntax supported by pythonBasic syntax supported by python
Basic syntax supported by python
 
Oops
OopsOops
Oops
 
Inheritance
InheritanceInheritance
Inheritance
 
Overloading
OverloadingOverloading
Overloading
 
Decision statements
Decision statementsDecision statements
Decision statements
 
Loop control statements
Loop control statementsLoop control statements
Loop control statements
 
Looping statements
Looping statementsLooping statements
Looping statements
 
Operators used in vb.net
Operators used in vb.netOperators used in vb.net
Operators used in vb.net
 
Frame class library and namespace
Frame class library and namespaceFrame class library and namespace
Frame class library and namespace
 
Introduction to .net
Introduction to .net Introduction to .net
Introduction to .net
 
Jsp basic
Jsp basicJsp basic
Jsp basic
 
Java script Basic
Java script BasicJava script Basic
Java script Basic
 
Sgml and xml
Sgml and xmlSgml and xml
Sgml and xml
 
Java script Advance
Java script   AdvanceJava script   Advance
Java script Advance
 
Html form
Html formHtml form
Html form
 
Html Concept
Html ConceptHtml Concept
Html Concept
 

Recently uploaded

How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Assessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptxAssessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptx
Kavitha Krishnan
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Assessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptxAssessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptx
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 

Keywords, identifiers and data type of vb.net

  • 2. 2 Content  Basic Syntax  Keywords  Identifiers  Comments  Data Type  Type Conversion
  • 3. 3 Basic Syntax VB.Net is an object-oriented programming language. In Object-Oriented Programming methodology, a program consists of various objects that interact with each other by means of actions. The actions that an object may take are called methods. Objects of the same kind are said to have the same type or, more often, are said to be in the same class. When we consider a VB.Net program, it can be defined as a collection of objects that communicate via invoking each other's methods. Let us now briefly look into what do class, object, methods and instance variables mean. Object − Objects have states and behaviors. Example: A dog has states - color, name, breed as well as behaviors - wagging, barking, eating, etc. An object is an instance of a class. Class − A class can be defined as a template/blueprint that describes the behaviors/states that objects of its type support. Methods − A method is basically a behavior. A class can contain many methods. It is in methods where the logics are written, data is manipulated and all the actions are executed. Instance Variables − Each object has its unique set of instance variables. An object's state is created by the values assigned to these instance variables.
  • 4. 4 Keywords  A keyword is a reserved word with special meanings in the compiler, whose meaning cannot be changed.  Therefore, these keywords cannot be used as an identifier in VB.NET programming such as class name, variable, function, module, etc.  Example : AddHandler, AddressOf, Alias, And, As, Boolean, ByRef, Byte, ByVal, Call, Case, Catch, Const , Continue, Dim, Do, Double, Each, Else, ElseIf, End, etc.
  • 5. 5 Identifiers  An identifier is a name used to identify a class, variable, function, or any other user-defined item.  There are various rules for identifier in VB.NET, as follows: 1. The first character of an identifier must start with an alphabet or underscore, that could be followed by any sequence of digits (0-9), letter or underscore. 2. An identifier should not contain any reserved keyword. 3. It should not start with any digit. 4. It should not more than 51 characters. 5. An identifier can contain two underscores, but should not be consecutive. 6. It should not include any commas or white spaces in-between characters. Some invalid identifiers are: 5be : First character should be alphabets or underscore (_) Class, Shared : Keyword are not allowed as identifier name. A# - : Identifier does not contain any special symbol. Avg marks : It should not contain any blank space. Some valid identifiers are: Value, a, rec1, my_data, Marks, num, etc
  • 6. 6 Comments  A comment is used to explain the various steps that we have taken in our programming. The compiler ignores these comment statements because the compiler is not executed or processed in VB.NET. Therefore, it does not take any place in your compilation code.  In VB.NET, we use ( ' ) symbol to comment a statement. Module Module1 Sub Main() 'Here Console.WriteLine() is used to print a statement. Console.WriteLine(" Welcome to world of .NET Programming") 'Above statement displays Welcome to world of .NET Programming End Sub End Module
  • 7. 7 VB.NET Data Type 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. In VB.NET, data type is used to define the type of a variable or function in a program. It also provide functionality for the conversion of one data type to another type using the data conversion function. For example, when we declare a variable, we have to tell the compiler what type of data or value is allocated to different kinds of variables to hold different amounts of space in computer memory. Syntax: Dim Variable_Name as DataType VariableName: It defines the name of the variable that you assign to store values. DataType: It represents the name of the data type that you assign to a variable.
  • 8. 8 VB.NET Data Type Data Types Required Space Value Range Boolean A Boolean type depends on the implementing platform True or False Byte 1 byte Byte Range start from 0 to 255 (unsigned) Char 2 bytes Char Range start from 0 to 65535 (unsigned) Date 8 bytes Date range can be 0:00:0 (midnight) January 1, 0001 to 11:5959 PM of December 31, 9999. Decimal 16 bytes Range from 0 to +/- 79,228,162,514,264,337,593,543,950,335 (+/-7.9…E+28) without any decimal point; And 0 to +/-7.92281625142264337593543950335 with 28 position to the right of the decimal Double 8 bytes -1.79769313486231570E+308 to -4.94- 65645841246544E-324 for negative values; 4.94065645841246544E-324 to 1.79769313486231570E+308, for positive values Integer 4 bytes -2,147,483,648 to 2,147,483,647 (signed) Long 8 bytes -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 (9.2…E + 18) (signed)
  • 9. 9 VB.NET Data Type Cont… Data Types Required Space Value Range Object Object size based on the platform such as 4 bytes in 32-bit and 8 bytes in 64-bit platform It can store any type of data defined in a variable of type Object SByte 1 byte -128 to 127 (signed) Short 2 bytes -32,768 to 32,767 (signed) Single 4 bytes -3.4028235E + 38 to -1.401298E-45 for negative values; And for positive value: 1.401298E-45 to 3.4028235E + 38. String String Datatype depend on the implementing platform It accepts Unicode character from 0 to approximately 2 billion characters. UInteger 4 bytes The range start from 0 to 4,294,967,295 (unsigned) ULong 8 bytes The range of ULong start from 0 to 18,446,744,073,709,551,615 (1.8…E + 19) (unsigned) User- Defined (structure) A user-defined data type depends on the implementing platform Each member of the structure has its own data type and limits independent of the other members' ranges. UShort 2 bytes Range from 0 to 65,535 (unsigned)
  • 10. 10 Example of Data Type Module Module1 Sub Main() Dim b As Byte = 1 Dim num As Integer = 5 Dim si As Single Dim db As Double Dim get_date As Date Dim c As Char Dim str As String b = 1 num = 20 si = 0.12 db = 2131.787 get_date = Today c = "A" str = "Hello Friends..." Console.WriteLine("Welcome to the DataType Demonstration") Console.WriteLine("Byte is: {0}", b) Console.WriteLine("Integer number is: {0}", num) Console.WriteLine("Single data type is: {0}", si) Console.WriteLine("Double data type is: {0}", db) Console.WriteLine("Today is: {0}", get_date) Console.WriteLine("Character is: {0}", b) Console.WriteLine("String message is: {0}", str) Console.ReadKey() End Sub End Module
  • 11. 11 Type Conversion Functions VB.Net provides the following in-line type conversion functions − 1. CBool(expression): It is used to convert an expression into a Boolean data type. 2. CByte(expression): It is used to convert an expression to a Byte data type. 3. CChar(expression): It is used to convert an expression to a Char data type. 4. CDate(expression): It is used to convert an expression to a Date data type. 5. CDbl(expression): It is used to convert an expression into a Double data type. 6. CDec(expression): It is used to convert an expression into a Decimal data type. 7. CInt(expression): It is used to convert an expression to an Integer data type. 8. CLng(expression): It is used to convert an expression to a Long data type. 9. CObj(expression): It is used to convert an expression to an Object data type. 10. CSByte(expression): It is used to convert an expression to an SByte data type. 11. CShort(expression): It is used to convert an expression to a Short data type. 12. CSng(expression): It is used to convert an expression into a Single data type. 13. CStr(expression): It is used to convert an expression into a String data type. 14. CUInt(expression): It is used to convert an expression to a UInt data type. 15. CULng(expression): It is used to convert an expression to a ULng data type. 16. CUShort(expression): It is used to convert an expression into a UShort data type.
  • 12. 12 Example of Type Conversion Module Module1 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