Datatypesandoperatorsinvb
Datatypesandoperatorsinvb
net:
The data types of a programming element refer to what kind of data it can hold and how it
stores that data.
A data type, in programming, is a classification that specifies which type of value a variable
has and what type of mathematical, relational or logical operations can be applied to it without
causing an error. A string, for example, is a data type that is used to classify text and an
integer is a data type used to classify whole number
5: Date.
1) Boolean:
A Boolean stores a value indicating True or False. It can be used as an expression in
an If-statement. It can also store the result of an expression. Booleans are used
throughout VB.NET programs.
Value = true
Or
Value = False.
Login = true
2) Integers:
Integer is a core type in VB.NET programs. It is the default numeric type. Usually
loops use the Integer type for their indexes. An Integer is declared with a Dim
statement. It can store positive values, such as 1, and negative values, such as -1.
In integers we take whole number.
Example:we make a program where you want that users enter their age so, when they enter
their age you need to define variables.
Percentage=78.9
Decimal values cannot be stored in integer because in integernumbers we can store only whole
number that is without decimal point.
Example:
Username = “Fatima”
City = “Quetta”
5) Date:
A date is value type which contains date values, time values, or date and time values.
Today = now()
Double 8 bytes
-1.79769313486231570E+308 through -
4.94065645841246544E-324, for
negative values
4.94065645841246544E-324 through
1.79769313486231570E+308, for
positive values
Single 4 bytes
-3.4028235E+38 through -1.401298E-45
for negative values;
Operators in VB.Net:
An operator is a symbol that tells the compiler to perform specific mathematical or
logical manipulations. VB.Net is rich in built -in operators and provides following types of
commonly used operators:
Arithmetic Operators
Comparison Operators
Logical/Bitwise Operators
Assignment Operators
Concatenation
Arithmetic Operators
This table shows all the arithmetic operators. Assume variable A holds 2 and
variable B holds 7, then:
Comparison Operators
This table shows all the comparison operators. Assume variable A holds 10 and
variable B holds 20, then:
Operator Description Example
<> Checks if the values of two operands are equal or not; if (A <> B)
values are not equal, then condition becomes true. is true.
> Checks if the value of left operand is greater than the (A > B)
value of right operand; if yes, then condition becomes is not
true. true.
< Checks if the value of left operand is less than the value of (A < B)
right operand; if yes, then condition becomes true. is true.
>= Checks if the value of left operand is greater than or equal (A >= B)
to the value of right operand; if yes, then condition is not
becomes true. true.
<= Checks if the value of left operand is less than or equal to (A <= B)
the value of right operand; if yes, then condition becomes is true.
true.
Logical/Bitwise Operators
This table shows all the logical operators. Assume variable A holds Boolean value True
and variable B holds Boolean Value False, then:
And It is the logical as well as bitwise AND operator. If both the (A And
operands are true, then condition becomes true. This B) is
operator does not perform short-circuiting, i.e., it False.
evaluates both the expressions.
Name = Fatima
Enroll = S14/BSCS/49
Semester = 7th