sWEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

ASP.NET Razor - VB Variables


Variables are named elements used to store data.


Variables

Variables are utilized to store data.

The name of a variable must start with an alphabetic character and can't contain whitespace or saved characters.

A variable can be of a explicit sort, demonstrating the sort of information it stores. String factors store string esteems ("Welcome to welookups"), whole number factors store number qualities (103), date factors store date esteems, etc.

Variables are proclaimed utilizing the Dim watchword, or by utilizing the sort (in the event that you need to announce the sort), in any case, ASP.NET can generally decide information types automatically.

Examples

/ Utilizing the Dim keyword:
Dim welcoming = "Welcome to welookups"
Diminish counter = 103
Dim today = DateTime.Today

//Using information types:
Diminish welcoming As String = "Welcome to welookups"
Dim counter As Integer = 103
Dim today As DateTime = DateTime.Today

Data Types

Below is a rundown of  normal information types:

Type Description Examples
integer Integer (entire numbers) 103, 12, 5168
double 64 bit drifting point number 3.14, 3.4e38
decimal Decimal number (higher precision) 1037.196543
boolean Boolean true, false
string String "Hello welookups", "John"

Operators

An administrator reveals to ASP.NET what sort of direction to perform in an expression.

 The VB language underpins numerous administrators. The following is a rundown of normal operators:

Operator Description Example
= Assigns an incentive to a variable. i=6
+
-
*
/
Adds an esteem or variable.
Subtracts an esteem or variable.
Multiplies a esteem or variable.
Divides an esteem or variable.
i=5+5
i=5-5
i=5*5
i=5/5
+=
-=
Increments a variable.
Decrements a variable.
i += 1
i - = 1
= Equality. Returns genuine if values are equal. if i=10
<> Inequality. Returns genuine if values are not equal. if <>10
<
>
<=
>=
Less than.
Greater than.
Less than or equal.
Greater than or equal.
if i<10
if i>10
if i<=10
if i>=10
& Adding strings (concatenation). "w3" & "schools"
. Dot. Separate articles and methods. DateTime.Hour
() Parenthesis. Gatherings values. (i+5)
() Parenthesis. Passes parameters. x=Add(i,5)
() Parenthesis. Gets to values in exhibits or collections. name(3)
Not Not. Inverts genuine or false. if Not ready
And
OR
Logical AND.
Logical OR.
if prepared And clear
if prepared Or clear
AndAlso
orElse
Extended Logical AND.
Extended Logical OR.
if prepared AndAlso clear
if prepared OrElse clear

Converting Data Types

Converting starting with one information type then onto the next is here and there useful.

The most basic precedent is to change over string contribution to another sort, for example, a number or a date.

As a standard, client input comes as strings, regardless of whether the client entered a number. In this way, numeric info esteems must be changed over to numbers before they can be utilized in calculations.

Below is a rundown of normal transformation methods:

Method Decryptions Example
AsInt()
IsInt()
Converts a string to an integer. if myString.IsInt() then
   myInt=myString.AsInt()
end if
AsFloat()
IsFloat()
Converts a string to a drifting point number. if myString.IsFloat() then
   myFloat=myString.AsFloat()
end if
AsDecimal()
IsDecimal()
Converts a string to a decimal number. if myString.IsDecimal() then
   myDec=myString.AsDecimal()
end if
AsDateTime()
IsDateTime()
Converts a string to an ASP.NET DateTime type. myString="10/10/2012"
myDate=myString.AsDateTime()
AsBool()
IsBool()
Converts a string to a Boolean. myString="True"
myBool=myString.AsBool()
ToString() Converts any information type to a string. myInt=1234
myString=myInt.ToString()