Download course VB : programming in ASP.NET
Download course VB : programming in ASP.NET
Creating
Variables Example
As it was mentioned before, ASP.NET
supports several languages such as VB.NET, C-Sharp and J-Script. In this
section, we will discuss how VB.NET program structures are implemented in
ASP.NET pages. Mainly, we will some examples.
Using Variables
Variables are used in all programming
language to hold data during the run-time of a program. All variables are
declared within the
The
contents of CapitalCityOfUk is:
The contents of NumberOfStates
is:
The contents of IndependenceDay
is:
Using Various Data Types
VB.NET and hence the ASP.NET supports a
variety of data types such as integer (short and long), decimal (single and
double), char, string, date, Boolean, etc. Most of these data types can be used
in arithmetic operations, comparison operations, and string concatenations. The following is an example that declares few
integer and decimal variables and performs a simple tax calculation. Again, the page load event is used to perform
the calculation, and there is no user interaction.
|
Your total earnings after tax are $
Concatenating Strings
String concatenation is common in an
ASP.NET page. The following codes show how strings can be combined or
concatenated using & and + signs in two different ways.
Example 1: Using values and & sign
strCombine =
“Jack” & “ “ & “Jill”
The result when strCombine is displayed:
Jack Jill
Example 2: Using Variables and &
sign
Dim
firstString As String
Dim
secondString As String
Dim twoString
As String
firstString =
“I am a “
secondString
= “graduate student“
twoString =
firstString & secondString
The result when strCombine is displayed:
I am a graduate student
Arrays
ASP.NET also supports array data type.
Thus multiple values of a particular data type can be stored in an array. Note
that in VB.NEt array index starts with 0. Thus a 10-member array should be
declared as 0-9. The following is an example of an one-dimensional array in
which text values are read from three input boxes and are stored in an array. The
function “CStr” is used to delete any empty spaces in the input texts and the
texts are displayed.
|
Please enter your name:
Please enter your address:
textmode="multiline"
/>
Please enter your chosen
password:
textmode="password"
/>
Control Structures
Various control structures are used in
any programming language such as
·
If.. Then .. Else
·
Select Case
·
For ... Next
·
Do While ...
·
For .... Each.......
0 commentaires: