SlideShare a Scribd company logo
ASP.NET Visual Basic
Web Form Introduction 1
What we will cover
● After starting the project and generating the
code behind file, we learn a little on OOP
(Object Oriented Programming)
○ Class and what a Class may contain
○ Inheritance
○ Namespace
○ Access Levels
● The very first subroutine - Page_Load, which
execute every time the page is loaded.
● After that we move to Button_Click
subroutine, which execute when button is
clicked
What we will cover
● Variables: valid and invalid variable naming
● Data types: Integer, String, Boolean,
Decimal
● Decision making using IF … ElseIf … Else
… End If
Tool: Visual Studio 2012 or 2013
● Download a FREE Visual Studio Express
https://www.visualstudio.com/en-us/products/visual-studio-express-vs.aspx
● Launch Visual Studio and click on “New
Project””.
DateAndTimeApp
New Web Form: PageLoad
New Web Form: PageLoad
Go to Code behind page
● Click anywhere outside the Div box to go to
the “Code Behind”file:
PageLoad.aspx.vb
Name of the auto-generated code behind file
always same as the Web Form (PageLoad.
aspx) and add “.vb” extension
Class and End Class
Every Web Form is an Object.
To define an object use “Class” and “End
Class”
What does a Class contain?
Eg: Label Class
What is Constructor
When Label
icon on the
ToolBox is
double click =>
to create a
Label object
on the page
What are Properties
What are Events
What are Methods
Group of
processing
that we could
ask the object
to do
Inherits from parent class
What do you get? You get for free “all” the
parent’s constructor, properties, events and
methods. So you just need to add new stuff.
Namespace (x.y.z) to prevent conflict
Instead of just call it “Page”, Microsoft calls its
Page class as “System.Web.UI.Page”.
Someone else may provide another “Page”
class but call theirs “Someone.Else.Page”.
It is similar to a fullname of a person so as not
to be mistaken.
Public, Protected, Private
● Public => anyone can
use it
● Protected => Only those
in the same Class can
use it + children Class
can use it too
● Private => Only those in
the same Class can use
it
These are called Access levels..
Page_Load Subroutine Our
Program to
be added
here. Will
be executed
every time
the web
form Page
is Loaded!
Our first App
When the application is run
1. a input will ask the users to key in their
name.
2. another input will ask for their designation
(Mr, Mrs, Ms, Miss).
3. Output a message: “Your name is xxxx, your
designation is xx.”
Use libraries provided
by Microsoft
Before you reinvent the
wheel and start to type
code straight away, look
for a suitable method from
the libraries provided:
Visual basic asp.net programming introduction
Visual basic asp.net programming introduction
Visual basic asp.net programming introduction
Variables
● A variable is a letter (eg x, y, z) or name
(score, highScore, health) that can store a
value.
● When you create computer programs, you
can use variables to store numbers, such as
the height of a building, or words, such as a
person's name.
There are three steps to using a
variable
1. Declare the variable: Tell the program the
name and kind of variable you want to use.
2. Assign the variable: Give the variable a
value to hold.
3. Use the variable: Retrieve the value held in
the variable and use it in your program.
Declare
● When you declare a variable, you have to
decide what to name it and what data type to
assign to it.
● You can name the variable anything that you
want, as long as the name starts with a letter
or an underscore. The 2nd and subsequent
characters may be letters or underscores or
numbers,
Declare
● When you use a name that describes what
the variable is holding, your code is easier to
read.
● For example, a variable that tracks the
number of pieces of candy in a jar could be
named totalCandy.
Declare
You declare a variable using the Dim and As
keywords, as shown here.
Dim aNumber As Integer
Variable Type
Assign
aNumber = 42
Declare and Assign
Dim aNumber As Integer = 42
Avoid Keywords
Avoid using keywords as variable Eg Dim, As,
Integer, String, etc
http://alturl.com/ix85i
Cannot include Space
Variable name cannot contain SPACES or
special characters such as !@#&-+....
Dim favourite fruit As String
Use one of the following conventions for
readability:
favouriteFruit or favourite_fruit
Cannot have space
Valid & Invalid variable names
Valid
i
x
_special_power
a1
alien1
Invalid
special power
special-power
1alien
reg#
Data Types
http://alturl.com/6vg9j
● Boolean for true and false
● Decimal
● Integer
● String
● Date
:
:
Visual basic asp.net programming introduction
Modify our app
When the application is run
1. a input will ask the users to key in their age.
2. another input will ask for their height (in
metre).
3. Output a message: “yy is your age and zz in
metre is your height.”
Exercise: Try to do it on your own!
When the application is run
1. a input will ask the users to key in their
favourite fruit.
2. another input will ask for their weight (in kg).
3. yet another input to ask for their contact
numbers.
4. Output a message: “Your favourite fruit is
apple, your weight is 75kg and 9765235 is
your contact number.”
Variables and Strings
Summary
Names for variable
Variable name cannot contain SPACES or
special characters such as !@#&-+....
Dim favourite fruit As String
Use one of the following conventions for
readability:
favouriteFruit or favourite_fruit
Cannot have space
Valid & Invalid variable names
Valid
i
x
_special_power
a1
alien1
Invalid
special power
special-power
1alien
reg#
Declaration of Variables
Dim fruit As String
Dim weight As String
Dim contact As String
Dim output As String
Instead of defining 4 string variables in
separate lines, combine them into one by
separating the variables with comma
Dim fruit,weight,contact,output As String
VS2012 will auto add space after comma!
Strings
“This is a string” - anything from the start
quotation to the end quotation is one string.
Use & to combine two strings into one longer
string:
“An apple a day” & “keep doc away!”
=> “An apple a daykeep doc away!”
How to have a space?
“An apple a day” & “ keep doc away!”
=> “An apple a day keep doc away!”
“An apple a day ” & “keep doc away!”
=> “An apple a day keep doc away!”
Add a space before k
Add a space after y
“An ” & “apple a day ” & “keep doc away!”
will combine the three strings into one longer
string:
“An apple a day keep doc away!”
Variables and Strings
fruit = “apple”
weight = “75”
“I like ” & fruit & “ and my wt in kg is ” & weight
“I like ” & fruit & “ and my wt in kg is ” & weight
will combine 4 strings into one longer string
“I like apple and my wt in kg is 75”
output = “I like ” & fruit & “ and my wt in kg is ” & weight
“I like apple and my wt in kg is 75”
The combine string is assigned to output
Step 1
Step 2
ASP.NET Visual Basic
Web Form Introduction 2
Get Started
Launch VS2012
New Project: DateAndTimeApp2
Add new item > Web Form: LoadPage2
Double click anywhere outside the “Div”
box, to generate the *.vb code file.
First attempt
When the application is run
1. Output a message: “Time now is xx:xx:xx
AM”
Libraries provided by
Microsoft
Before you reinvent the
wheel and start to type
straight away, look for a
suitable one from the
libraries provided:
Visual basic asp.net programming introduction
Visual basic asp.net programming introduction
Visual basic asp.net programming introduction
Visual basic asp.net programming introduction
output = “Time now is ” & TimeOfDay
“Time now is 09:15:36 AM”
The combine string is assigned to output
Step 1
Step 2
Modify App
When the application is run
1. Ask user to key in a month from 1 to 12. Eg
1.
2. Output a message: “The month is January.”
The month displayed will depends on the
input of the user.
Visual basic asp.net programming introduction
Parameters
Visual basic asp.net programming introduction
Visual basic asp.net programming introduction
Exercise: Try to do on your own!
When the application is run
1. Ask user to key in a month from 1 to 12. Eg
5.
2. Output a message: “You have key in 5 and
the month is May.” The number and month
displayed will depends on the input of the
user.
ASP.NET Visual Basic
Web Form Introduction 3
Get Started
Launch VS2012
New Project: GuessNumber
Add new item > Web Form: BtnClick
Switch the web form to
“Design View”. Then drag
the various control from the
Toolbox window. finally set
their properties using the
Properties Window.
Page Title
Method 1:
1. Switch to source view.
2. Edit <title></title>.
Method 2:
In Properties window:
1. Select “DOCUMENT” from dropdown.
2. Add/modify “Title” property.
Visual basic asp.net programming introduction
This App need to
generate a random
number for user to
guess when the web
page is loaded. The
same number should
remain till the game
is over.
Visual basic asp.net programming introduction
Visual basic asp.net programming introduction
Visual basic asp.net programming introduction
Get content from Web Control
guess = txtAnswer.Text
txtAnswer.Text property
Set content to Web Control
lblResults.text = “Guess correctly.”
lblResults.Text property
Display
updated
Decision making and Branching
Guess is correct?
Yes
No
“Guess Correctly.”
“The hidden number is 8”
If … Then … Else … End If
If (Guess is correct?) Then
output “Guess Correctly.”
Else
output “The hidden number is 8”
End If
Flowchart Pseudocode
Condition
If (Guess is correct?) Then
output “Guess Correctly.”
Else
output “The hidden number is 8”
End If
Condition
Guess is correct?
is guess same as hiddenNumber?
guess = hiddenNumber
Pseudocode
Pseudocode
VB code
VB Code
If … Then … Else … End If
If guess = hiddenNumber Then
lblResults.Text = “Guess Correctly.”
Else
lblResults.Text =“The hidden number is 8”
End If
Visual basic asp.net programming introduction
Exercise
Modify the App
1. to generate hidden number from 11 to 15
instead of 1 to 10.
2. to clear the txtAnswer.Text after each guess.
(Hint: “” => blank)
Visual basic asp.net programming introduction
ASP.NET Visual Basic
Web Form Introduction 4
Get Started
Launch VS2012
New Project: ControlStatus
Add new item > Web Form: BtnClick
6 Labels
Textbox
Quick and dirty for proof-of-concept:
Use the default names provided - TextBox1, Label1 to
Label6, CheckBox1, RadioButton1 to RadioButton2 and
Button1
The status of each control to be
updated on the label next to it
The status of each control
to be updated on the label
next to it
Quick and dirty
for proof-of-
concept:
Use the properties
from the controls
directly without
using variables.
ASP.NET Visual Basic
Web Form Introduction 5
Get Started
Launch VS2012
New Project: ConvertMonth2
Add new item > Web Form: MonthName
Visual basic asp.net programming introduction
Visual basic asp.net programming introduction
Set content:
cbPopup.Checked = True OR
cbPopup.Checked = False
Visual basic asp.net programming introduction
Exercise:
use txtMonthInteger.Text
use lblResults.Text
HINT:
Visual basic asp.net programming introduction
Visual basic asp.net programming introduction
If … Then … End If
is cbPopup
Checked?
Yes
Popup: “Month is January”
Only need “YES” branch.
No need to use “Else” in
VB code.
HINT:
If cbPopup.Checked = True Then
….
EndIf
Visual basic asp.net programming introduction
Checking for valid input
Input is 1?
Yes
No
Process normally
Input is 2?
Yes
No
Process normally
Flowchart
Input is 3?
Yes
If ... Then … Else If … Then ….
Pseudocode
If monthNumber = 1 Then
Process normally
ElseIf monthNumber = 2 Then
Process normally
ElseIf monthNumber = 3 Then
Process normally
:
End If
Visual basic asp.net programming introduction
Subroutines for code reuse
Variables declaration moved
to outside the subroutine, so
that they can be access from
all the subroutines including
btnConvert_Click() and
myFunc().
Common codes are moved
into a new subroutine -
myFunc().
If … ElseIf … Else … EndIf
Summary
If … ElseIf … Else … EndIf
Type 1
If Condition Then
Processing
End If
Type 2
If Condition Then
Processing
Else
Processing
End If
If … ElseIf … Else … EndIf
Type 3
If Condition1 Then
Processing
ElseIf Condition2 Then
Processing
End If
Type 3++
If Condition1 Then
Processing
ElseIf Condition2 Then
Processing
ElseIf Condition3 Then
Processing
End If
If … ElseIf … Else … EndIf
Type 4
If Condition1 Then
Processing
ElseIf Condition2 Then
Processing
Else
Processing
End If
Type 4++
If Condition1 Then
Processing
ElseIf Condition2 Then
Processing
ElseIf Condition3 Then
Processing
Else
Processing
End If
This is just an introduction.
Happy programming!

More Related Content

What's hot (20)

Windows Forms For Beginners Part - 3
Windows Forms For Beginners Part - 3Windows Forms For Beginners Part - 3
Windows Forms For Beginners Part - 3
Bhushan Mulmule
 
selection structures
selection structuresselection structures
selection structures
Micheal Ogundero
 
Basic c# cheat sheet
Basic c# cheat sheetBasic c# cheat sheet
Basic c# cheat sheet
Ahmed Elshal
 
Java script basics
Java script basicsJava script basics
Java script basics
Thakur Amit Tomer
 
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia InstituteMVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
Ravi Bhadauria
 
Maxbox starter
Maxbox starterMaxbox starter
Maxbox starter
Max Kleiner
 
Csphtp1 13
Csphtp1 13Csphtp1 13
Csphtp1 13
HUST
 
Android tutorials7 calulator_improve
Android tutorials7 calulator_improveAndroid tutorials7 calulator_improve
Android tutorials7 calulator_improve
Vlad Kolesnyk
 
Lec 10
Lec 10Lec 10
Lec 10
kapil078
 
05 control structures 2
05 control structures 205 control structures 2
05 control structures 2
Jomel Penalba
 
Labsheet 4
Labsheet 4Labsheet 4
Labsheet 4
rohassanie
 
Understanding F# Workflows
Understanding F# WorkflowsUnderstanding F# Workflows
Understanding F# Workflows
mdlm
 
Learning R while exploring statistics
Learning R while exploring statisticsLearning R while exploring statistics
Learning R while exploring statistics
Dorothy Bishop
 
Intro To C++ - Class 04 - An Introduction To C++ Programming, Part III
Intro To C++ - Class 04 - An Introduction To C++ Programming, Part IIIIntro To C++ - Class 04 - An Introduction To C++ Programming, Part III
Intro To C++ - Class 04 - An Introduction To C++ Programming, Part III
Blue Elephant Consulting
 
Vb (1)
Vb (1)Vb (1)
Vb (1)
Rajeev Sharan
 
Pseudocode By ZAK
Pseudocode By ZAKPseudocode By ZAK
Pseudocode By ZAK
Tabsheer Hasan
 
Антон Молдован "Type driven development with f#"
Антон Молдован "Type driven development with f#"Антон Молдован "Type driven development with f#"
Антон Молдован "Type driven development with f#"
Fwdays
 
Basic computer-programming-2
Basic computer-programming-2Basic computer-programming-2
Basic computer-programming-2
lemonmichelangelo
 
Python - Control Structures
Python - Control StructuresPython - Control Structures
Python - Control Structures
LasithNiro
 
Form Validation in JavaScript
Form Validation in JavaScriptForm Validation in JavaScript
Form Validation in JavaScript
Ravi Bhadauria
 
Windows Forms For Beginners Part - 3
Windows Forms For Beginners Part - 3Windows Forms For Beginners Part - 3
Windows Forms For Beginners Part - 3
Bhushan Mulmule
 
Basic c# cheat sheet
Basic c# cheat sheetBasic c# cheat sheet
Basic c# cheat sheet
Ahmed Elshal
 
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia InstituteMVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
Ravi Bhadauria
 
Csphtp1 13
Csphtp1 13Csphtp1 13
Csphtp1 13
HUST
 
Android tutorials7 calulator_improve
Android tutorials7 calulator_improveAndroid tutorials7 calulator_improve
Android tutorials7 calulator_improve
Vlad Kolesnyk
 
05 control structures 2
05 control structures 205 control structures 2
05 control structures 2
Jomel Penalba
 
Understanding F# Workflows
Understanding F# WorkflowsUnderstanding F# Workflows
Understanding F# Workflows
mdlm
 
Learning R while exploring statistics
Learning R while exploring statisticsLearning R while exploring statistics
Learning R while exploring statistics
Dorothy Bishop
 
Intro To C++ - Class 04 - An Introduction To C++ Programming, Part III
Intro To C++ - Class 04 - An Introduction To C++ Programming, Part IIIIntro To C++ - Class 04 - An Introduction To C++ Programming, Part III
Intro To C++ - Class 04 - An Introduction To C++ Programming, Part III
Blue Elephant Consulting
 
Антон Молдован "Type driven development with f#"
Антон Молдован "Type driven development with f#"Антон Молдован "Type driven development with f#"
Антон Молдован "Type driven development with f#"
Fwdays
 
Basic computer-programming-2
Basic computer-programming-2Basic computer-programming-2
Basic computer-programming-2
lemonmichelangelo
 
Python - Control Structures
Python - Control StructuresPython - Control Structures
Python - Control Structures
LasithNiro
 
Form Validation in JavaScript
Form Validation in JavaScriptForm Validation in JavaScript
Form Validation in JavaScript
Ravi Bhadauria
 

Similar to Visual basic asp.net programming introduction (20)

Ch (2)(presentation) its about visual programming
Ch (2)(presentation) its about visual programmingCh (2)(presentation) its about visual programming
Ch (2)(presentation) its about visual programming
nimrastorage123
 
Sharbani bhattacharya VB Structures
Sharbani bhattacharya VB StructuresSharbani bhattacharya VB Structures
Sharbani bhattacharya VB Structures
Sharbani Bhattacharya
 
CHAPTER 3 - Lesson B
CHAPTER 3 - Lesson BCHAPTER 3 - Lesson B
CHAPTER 3 - Lesson B
MLG College of Learning, Inc
 
Lesson 5 Introduction to Human Computer Interaction
Lesson 5 Introduction to Human Computer InteractionLesson 5 Introduction to Human Computer Interaction
Lesson 5 Introduction to Human Computer Interaction
EllenGracePorras
 
Ms vb
Ms vbMs vb
Ms vb
sirjade4
 
Vb introduction.
Vb introduction.Vb introduction.
Vb introduction.
sagaroceanic11
 
Visualbasic tutorial
Visualbasic tutorialVisualbasic tutorial
Visualbasic tutorial
Andi Simanjuntak
 
Introduction to VB.Net By William Lacktano.ppt
Introduction to VB.Net By William Lacktano.pptIntroduction to VB.Net By William Lacktano.ppt
Introduction to VB.Net By William Lacktano.ppt
DonWilliam5
 
COM 211 PRESENTATION.pptx
COM 211 PRESENTATION.pptxCOM 211 PRESENTATION.pptx
COM 211 PRESENTATION.pptx
AnasYunusa
 
Vb6.0 intro
Vb6.0 introVb6.0 intro
Vb6.0 intro
JOSEPHINEA6
 
Visual basic intoduction
Visual basic intoductionVisual basic intoduction
Visual basic intoduction
mohamedsaad24
 
Visual Basic Review - ICA
Visual Basic Review - ICAVisual Basic Review - ICA
Visual Basic Review - ICA
emtrajano
 
UNIT I.pptx
UNIT I.pptxUNIT I.pptx
UNIT I.pptx
BhargaviJ8
 
CHAPTER 3- Lesson A
CHAPTER 3- Lesson ACHAPTER 3- Lesson A
CHAPTER 3- Lesson A
MLG College of Learning, Inc
 
Solution Manual for Programming with Microsoft Visual Basic 2017 8th by Zak
Solution Manual for Programming with Microsoft Visual Basic 2017 8th by ZakSolution Manual for Programming with Microsoft Visual Basic 2017 8th by Zak
Solution Manual for Programming with Microsoft Visual Basic 2017 8th by Zak
albazegermai
 
.NET Variables and Data Types
.NET Variables and Data Types.NET Variables and Data Types
.NET Variables and Data Types
LearnNowOnline
 
CHAPTER 2 (Data types,Variables) in Visual Basic Programming
CHAPTER 2 (Data types,Variables) in Visual Basic ProgrammingCHAPTER 2 (Data types,Variables) in Visual Basic Programming
CHAPTER 2 (Data types,Variables) in Visual Basic Programming
abacusgtuc
 
Vb tutorial
Vb tutorialVb tutorial
Vb tutorial
jayguyab
 
Vb tutorial
Vb tutorialVb tutorial
Vb tutorial
Saikarthik103212
 
VISUAL BASIC 6 - CONTROLS AND DECLARATIONS
VISUAL BASIC 6 - CONTROLS AND DECLARATIONSVISUAL BASIC 6 - CONTROLS AND DECLARATIONS
VISUAL BASIC 6 - CONTROLS AND DECLARATIONS
Suraj Kumar
 
Ch (2)(presentation) its about visual programming
Ch (2)(presentation) its about visual programmingCh (2)(presentation) its about visual programming
Ch (2)(presentation) its about visual programming
nimrastorage123
 
Lesson 5 Introduction to Human Computer Interaction
Lesson 5 Introduction to Human Computer InteractionLesson 5 Introduction to Human Computer Interaction
Lesson 5 Introduction to Human Computer Interaction
EllenGracePorras
 
Introduction to VB.Net By William Lacktano.ppt
Introduction to VB.Net By William Lacktano.pptIntroduction to VB.Net By William Lacktano.ppt
Introduction to VB.Net By William Lacktano.ppt
DonWilliam5
 
COM 211 PRESENTATION.pptx
COM 211 PRESENTATION.pptxCOM 211 PRESENTATION.pptx
COM 211 PRESENTATION.pptx
AnasYunusa
 
Visual basic intoduction
Visual basic intoductionVisual basic intoduction
Visual basic intoduction
mohamedsaad24
 
Visual Basic Review - ICA
Visual Basic Review - ICAVisual Basic Review - ICA
Visual Basic Review - ICA
emtrajano
 
Solution Manual for Programming with Microsoft Visual Basic 2017 8th by Zak
Solution Manual for Programming with Microsoft Visual Basic 2017 8th by ZakSolution Manual for Programming with Microsoft Visual Basic 2017 8th by Zak
Solution Manual for Programming with Microsoft Visual Basic 2017 8th by Zak
albazegermai
 
.NET Variables and Data Types
.NET Variables and Data Types.NET Variables and Data Types
.NET Variables and Data Types
LearnNowOnline
 
CHAPTER 2 (Data types,Variables) in Visual Basic Programming
CHAPTER 2 (Data types,Variables) in Visual Basic ProgrammingCHAPTER 2 (Data types,Variables) in Visual Basic Programming
CHAPTER 2 (Data types,Variables) in Visual Basic Programming
abacusgtuc
 
Vb tutorial
Vb tutorialVb tutorial
Vb tutorial
jayguyab
 
VISUAL BASIC 6 - CONTROLS AND DECLARATIONS
VISUAL BASIC 6 - CONTROLS AND DECLARATIONSVISUAL BASIC 6 - CONTROLS AND DECLARATIONS
VISUAL BASIC 6 - CONTROLS AND DECLARATIONS
Suraj Kumar
 
Ad

More from Hock Leng PUAH (20)

ASP.net Image Slideshow
ASP.net Image SlideshowASP.net Image Slideshow
ASP.net Image Slideshow
Hock Leng PUAH
 
Using iMac Built-in Screen Sharing
Using iMac Built-in Screen SharingUsing iMac Built-in Screen Sharing
Using iMac Built-in Screen Sharing
Hock Leng PUAH
 
Hosting SWF Flash file
Hosting SWF Flash fileHosting SWF Flash file
Hosting SWF Flash file
Hock Leng PUAH
 
PHP built-in functions date( ) and mktime( ) to calculate age from date of birth
PHP built-in functions date( ) and mktime( ) to calculate age from date of birthPHP built-in functions date( ) and mktime( ) to calculate age from date of birth
PHP built-in functions date( ) and mktime( ) to calculate age from date of birth
Hock Leng PUAH
 
PHP built-in function mktime example
PHP built-in function mktime examplePHP built-in function mktime example
PHP built-in function mktime example
Hock Leng PUAH
 
A simple php exercise on date( ) function
A simple php exercise on date( ) functionA simple php exercise on date( ) function
A simple php exercise on date( ) function
Hock Leng PUAH
 
Integrate jQuery PHP MySQL project to JOOMLA web site
Integrate jQuery PHP MySQL project to JOOMLA web siteIntegrate jQuery PHP MySQL project to JOOMLA web site
Integrate jQuery PHP MySQL project to JOOMLA web site
Hock Leng PUAH
 
Responsive design
Responsive designResponsive design
Responsive design
Hock Leng PUAH
 
Step by step guide to use mac lion to make hidden folders visible
Step by step guide to use mac lion to make hidden folders visibleStep by step guide to use mac lion to make hidden folders visible
Step by step guide to use mac lion to make hidden folders visible
Hock Leng PUAH
 
Beautiful web pages
Beautiful web pagesBeautiful web pages
Beautiful web pages
Hock Leng PUAH
 
CSS Basic and Common Errors
CSS Basic and Common ErrorsCSS Basic and Common Errors
CSS Basic and Common Errors
Hock Leng PUAH
 
Connectivity Test for EES Logic Probe Project
Connectivity Test for EES Logic Probe ProjectConnectivity Test for EES Logic Probe Project
Connectivity Test for EES Logic Probe Project
Hock Leng PUAH
 
Logic gate lab intro
Logic gate lab introLogic gate lab intro
Logic gate lab intro
Hock Leng PUAH
 
Ohm's law, resistors in series or in parallel
Ohm's law, resistors in series or in parallelOhm's law, resistors in series or in parallel
Ohm's law, resistors in series or in parallel
Hock Leng PUAH
 
Connections Exercises Guide
Connections Exercises GuideConnections Exercises Guide
Connections Exercises Guide
Hock Leng PUAH
 
Design to circuit connection
Design to circuit connectionDesign to circuit connection
Design to circuit connection
Hock Leng PUAH
 
NMS Media Services Jobshet 1 to 5 Summary
NMS Media Services Jobshet 1 to 5 SummaryNMS Media Services Jobshet 1 to 5 Summary
NMS Media Services Jobshet 1 to 5 Summary
Hock Leng PUAH
 
Virtualbox step by step guide
Virtualbox step by step guideVirtualbox step by step guide
Virtualbox step by step guide
Hock Leng PUAH
 
Nms chapter 01
Nms chapter 01Nms chapter 01
Nms chapter 01
Hock Leng PUAH
 
Pedagogic Innovation to Engage Academically Weaker Students
Pedagogic Innovation to Engage Academically Weaker StudentsPedagogic Innovation to Engage Academically Weaker Students
Pedagogic Innovation to Engage Academically Weaker Students
Hock Leng PUAH
 
ASP.net Image Slideshow
ASP.net Image SlideshowASP.net Image Slideshow
ASP.net Image Slideshow
Hock Leng PUAH
 
Using iMac Built-in Screen Sharing
Using iMac Built-in Screen SharingUsing iMac Built-in Screen Sharing
Using iMac Built-in Screen Sharing
Hock Leng PUAH
 
Hosting SWF Flash file
Hosting SWF Flash fileHosting SWF Flash file
Hosting SWF Flash file
Hock Leng PUAH
 
PHP built-in functions date( ) and mktime( ) to calculate age from date of birth
PHP built-in functions date( ) and mktime( ) to calculate age from date of birthPHP built-in functions date( ) and mktime( ) to calculate age from date of birth
PHP built-in functions date( ) and mktime( ) to calculate age from date of birth
Hock Leng PUAH
 
PHP built-in function mktime example
PHP built-in function mktime examplePHP built-in function mktime example
PHP built-in function mktime example
Hock Leng PUAH
 
A simple php exercise on date( ) function
A simple php exercise on date( ) functionA simple php exercise on date( ) function
A simple php exercise on date( ) function
Hock Leng PUAH
 
Integrate jQuery PHP MySQL project to JOOMLA web site
Integrate jQuery PHP MySQL project to JOOMLA web siteIntegrate jQuery PHP MySQL project to JOOMLA web site
Integrate jQuery PHP MySQL project to JOOMLA web site
Hock Leng PUAH
 
Step by step guide to use mac lion to make hidden folders visible
Step by step guide to use mac lion to make hidden folders visibleStep by step guide to use mac lion to make hidden folders visible
Step by step guide to use mac lion to make hidden folders visible
Hock Leng PUAH
 
CSS Basic and Common Errors
CSS Basic and Common ErrorsCSS Basic and Common Errors
CSS Basic and Common Errors
Hock Leng PUAH
 
Connectivity Test for EES Logic Probe Project
Connectivity Test for EES Logic Probe ProjectConnectivity Test for EES Logic Probe Project
Connectivity Test for EES Logic Probe Project
Hock Leng PUAH
 
Ohm's law, resistors in series or in parallel
Ohm's law, resistors in series or in parallelOhm's law, resistors in series or in parallel
Ohm's law, resistors in series or in parallel
Hock Leng PUAH
 
Connections Exercises Guide
Connections Exercises GuideConnections Exercises Guide
Connections Exercises Guide
Hock Leng PUAH
 
Design to circuit connection
Design to circuit connectionDesign to circuit connection
Design to circuit connection
Hock Leng PUAH
 
NMS Media Services Jobshet 1 to 5 Summary
NMS Media Services Jobshet 1 to 5 SummaryNMS Media Services Jobshet 1 to 5 Summary
NMS Media Services Jobshet 1 to 5 Summary
Hock Leng PUAH
 
Virtualbox step by step guide
Virtualbox step by step guideVirtualbox step by step guide
Virtualbox step by step guide
Hock Leng PUAH
 
Pedagogic Innovation to Engage Academically Weaker Students
Pedagogic Innovation to Engage Academically Weaker StudentsPedagogic Innovation to Engage Academically Weaker Students
Pedagogic Innovation to Engage Academically Weaker Students
Hock Leng PUAH
 
Ad

Recently uploaded (20)

How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18
Celine George
 
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Celine George
 
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
Quiz Club of PSG College of Arts & Science
 
Coleoptera: The Largest Insect Order.pptx
Coleoptera: The Largest Insect Order.pptxColeoptera: The Largest Insect Order.pptx
Coleoptera: The Largest Insect Order.pptx
Arshad Shaikh
 
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptxSEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
PoojaSen20
 
Search Engine Optimization (SEO) for Website Success
Search Engine Optimization (SEO) for Website SuccessSearch Engine Optimization (SEO) for Website Success
Search Engine Optimization (SEO) for Website Success
Muneeb Rana
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptxUnit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
Hemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptxHemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptx
Arshad Shaikh
 
How to Create a Stage or a Pipeline in Odoo 18 CRM
How to Create a Stage or a Pipeline in Odoo 18 CRMHow to Create a Stage or a Pipeline in Odoo 18 CRM
How to Create a Stage or a Pipeline in Odoo 18 CRM
Celine George
 
Adam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational PsychologyAdam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational Psychology
Prachi Shah
 
LDMMIA Reiki Yoga S8 Free Workshop Grad Level
LDMMIA Reiki Yoga S8 Free Workshop Grad LevelLDMMIA Reiki Yoga S8 Free Workshop Grad Level
LDMMIA Reiki Yoga S8 Free Workshop Grad Level
LDM & Mia eStudios
 
"Hymenoptera: A Diverse and Fascinating Order".pptx
"Hymenoptera: A Diverse and Fascinating Order".pptx"Hymenoptera: A Diverse and Fascinating Order".pptx
"Hymenoptera: A Diverse and Fascinating Order".pptx
Arshad Shaikh
 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptxAnalysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
Final Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptxFinal Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptx
bobby205207
 
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
parmarjuli1412
 
Stewart Butler - OECD - How to design and deliver higher technical education ...
Stewart Butler - OECD - How to design and deliver higher technical education ...Stewart Butler - OECD - How to design and deliver higher technical education ...
Stewart Butler - OECD - How to design and deliver higher technical education ...
EduSkills OECD
 
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Pests of Rice: Damage, Identification, Life history, and Management.pptx
Pests of Rice: Damage, Identification, Life history, and Management.pptxPests of Rice: Damage, Identification, Life history, and Management.pptx
Pests of Rice: Damage, Identification, Life history, and Management.pptx
Arshad Shaikh
 
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdfForestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
ChalaKelbessa
 
How to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 SalesHow to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 Sales
Celine George
 
How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18
Celine George
 
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Celine George
 
Coleoptera: The Largest Insect Order.pptx
Coleoptera: The Largest Insect Order.pptxColeoptera: The Largest Insect Order.pptx
Coleoptera: The Largest Insect Order.pptx
Arshad Shaikh
 
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptxSEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
PoojaSen20
 
Search Engine Optimization (SEO) for Website Success
Search Engine Optimization (SEO) for Website SuccessSearch Engine Optimization (SEO) for Website Success
Search Engine Optimization (SEO) for Website Success
Muneeb Rana
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptxUnit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
Hemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptxHemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptx
Arshad Shaikh
 
How to Create a Stage or a Pipeline in Odoo 18 CRM
How to Create a Stage or a Pipeline in Odoo 18 CRMHow to Create a Stage or a Pipeline in Odoo 18 CRM
How to Create a Stage or a Pipeline in Odoo 18 CRM
Celine George
 
Adam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational PsychologyAdam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational Psychology
Prachi Shah
 
LDMMIA Reiki Yoga S8 Free Workshop Grad Level
LDMMIA Reiki Yoga S8 Free Workshop Grad LevelLDMMIA Reiki Yoga S8 Free Workshop Grad Level
LDMMIA Reiki Yoga S8 Free Workshop Grad Level
LDM & Mia eStudios
 
"Hymenoptera: A Diverse and Fascinating Order".pptx
"Hymenoptera: A Diverse and Fascinating Order".pptx"Hymenoptera: A Diverse and Fascinating Order".pptx
"Hymenoptera: A Diverse and Fascinating Order".pptx
Arshad Shaikh
 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptxAnalysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
Final Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptxFinal Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptx
bobby205207
 
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
parmarjuli1412
 
Stewart Butler - OECD - How to design and deliver higher technical education ...
Stewart Butler - OECD - How to design and deliver higher technical education ...Stewart Butler - OECD - How to design and deliver higher technical education ...
Stewart Butler - OECD - How to design and deliver higher technical education ...
EduSkills OECD
 
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Pests of Rice: Damage, Identification, Life history, and Management.pptx
Pests of Rice: Damage, Identification, Life history, and Management.pptxPests of Rice: Damage, Identification, Life history, and Management.pptx
Pests of Rice: Damage, Identification, Life history, and Management.pptx
Arshad Shaikh
 
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdfForestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
ChalaKelbessa
 
How to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 SalesHow to Create Quotation Templates Sequence in Odoo 18 Sales
How to Create Quotation Templates Sequence in Odoo 18 Sales
Celine George
 

Visual basic asp.net programming introduction

  • 1. ASP.NET Visual Basic Web Form Introduction 1
  • 2. What we will cover ● After starting the project and generating the code behind file, we learn a little on OOP (Object Oriented Programming) ○ Class and what a Class may contain ○ Inheritance ○ Namespace ○ Access Levels ● The very first subroutine - Page_Load, which execute every time the page is loaded. ● After that we move to Button_Click subroutine, which execute when button is clicked
  • 3. What we will cover ● Variables: valid and invalid variable naming ● Data types: Integer, String, Boolean, Decimal ● Decision making using IF … ElseIf … Else … End If
  • 4. Tool: Visual Studio 2012 or 2013 ● Download a FREE Visual Studio Express https://www.visualstudio.com/en-us/products/visual-studio-express-vs.aspx ● Launch Visual Studio and click on “New Project””.
  • 6. New Web Form: PageLoad
  • 7. New Web Form: PageLoad
  • 8. Go to Code behind page ● Click anywhere outside the Div box to go to the “Code Behind”file:
  • 9. PageLoad.aspx.vb Name of the auto-generated code behind file always same as the Web Form (PageLoad. aspx) and add “.vb” extension
  • 10. Class and End Class Every Web Form is an Object. To define an object use “Class” and “End Class”
  • 11. What does a Class contain? Eg: Label Class
  • 12. What is Constructor When Label icon on the ToolBox is double click => to create a Label object on the page
  • 15. What are Methods Group of processing that we could ask the object to do
  • 16. Inherits from parent class What do you get? You get for free “all” the parent’s constructor, properties, events and methods. So you just need to add new stuff.
  • 17. Namespace (x.y.z) to prevent conflict Instead of just call it “Page”, Microsoft calls its Page class as “System.Web.UI.Page”. Someone else may provide another “Page” class but call theirs “Someone.Else.Page”. It is similar to a fullname of a person so as not to be mistaken.
  • 18. Public, Protected, Private ● Public => anyone can use it ● Protected => Only those in the same Class can use it + children Class can use it too ● Private => Only those in the same Class can use it These are called Access levels..
  • 19. Page_Load Subroutine Our Program to be added here. Will be executed every time the web form Page is Loaded!
  • 20. Our first App When the application is run 1. a input will ask the users to key in their name. 2. another input will ask for their designation (Mr, Mrs, Ms, Miss). 3. Output a message: “Your name is xxxx, your designation is xx.”
  • 21. Use libraries provided by Microsoft Before you reinvent the wheel and start to type code straight away, look for a suitable method from the libraries provided:
  • 25. Variables ● A variable is a letter (eg x, y, z) or name (score, highScore, health) that can store a value. ● When you create computer programs, you can use variables to store numbers, such as the height of a building, or words, such as a person's name.
  • 26. There are three steps to using a variable 1. Declare the variable: Tell the program the name and kind of variable you want to use. 2. Assign the variable: Give the variable a value to hold. 3. Use the variable: Retrieve the value held in the variable and use it in your program.
  • 27. Declare ● When you declare a variable, you have to decide what to name it and what data type to assign to it. ● You can name the variable anything that you want, as long as the name starts with a letter or an underscore. The 2nd and subsequent characters may be letters or underscores or numbers,
  • 28. Declare ● When you use a name that describes what the variable is holding, your code is easier to read. ● For example, a variable that tracks the number of pieces of candy in a jar could be named totalCandy.
  • 29. Declare You declare a variable using the Dim and As keywords, as shown here. Dim aNumber As Integer Variable Type
  • 31. Declare and Assign Dim aNumber As Integer = 42
  • 32. Avoid Keywords Avoid using keywords as variable Eg Dim, As, Integer, String, etc http://alturl.com/ix85i
  • 33. Cannot include Space Variable name cannot contain SPACES or special characters such as !@#&-+.... Dim favourite fruit As String Use one of the following conventions for readability: favouriteFruit or favourite_fruit Cannot have space
  • 34. Valid & Invalid variable names Valid i x _special_power a1 alien1 Invalid special power special-power 1alien reg#
  • 35. Data Types http://alturl.com/6vg9j ● Boolean for true and false ● Decimal ● Integer ● String ● Date : :
  • 37. Modify our app When the application is run 1. a input will ask the users to key in their age. 2. another input will ask for their height (in metre). 3. Output a message: “yy is your age and zz in metre is your height.”
  • 38. Exercise: Try to do it on your own! When the application is run 1. a input will ask the users to key in their favourite fruit. 2. another input will ask for their weight (in kg). 3. yet another input to ask for their contact numbers. 4. Output a message: “Your favourite fruit is apple, your weight is 75kg and 9765235 is your contact number.”
  • 40. Names for variable Variable name cannot contain SPACES or special characters such as !@#&-+.... Dim favourite fruit As String Use one of the following conventions for readability: favouriteFruit or favourite_fruit Cannot have space
  • 41. Valid & Invalid variable names Valid i x _special_power a1 alien1 Invalid special power special-power 1alien reg#
  • 42. Declaration of Variables Dim fruit As String Dim weight As String Dim contact As String Dim output As String Instead of defining 4 string variables in separate lines, combine them into one by separating the variables with comma Dim fruit,weight,contact,output As String VS2012 will auto add space after comma!
  • 43. Strings “This is a string” - anything from the start quotation to the end quotation is one string. Use & to combine two strings into one longer string: “An apple a day” & “keep doc away!” => “An apple a daykeep doc away!” How to have a space?
  • 44. “An apple a day” & “ keep doc away!” => “An apple a day keep doc away!” “An apple a day ” & “keep doc away!” => “An apple a day keep doc away!” Add a space before k Add a space after y
  • 45. “An ” & “apple a day ” & “keep doc away!” will combine the three strings into one longer string: “An apple a day keep doc away!”
  • 46. Variables and Strings fruit = “apple” weight = “75” “I like ” & fruit & “ and my wt in kg is ” & weight
  • 47. “I like ” & fruit & “ and my wt in kg is ” & weight will combine 4 strings into one longer string “I like apple and my wt in kg is 75”
  • 48. output = “I like ” & fruit & “ and my wt in kg is ” & weight “I like apple and my wt in kg is 75” The combine string is assigned to output Step 1 Step 2
  • 49. ASP.NET Visual Basic Web Form Introduction 2
  • 50. Get Started Launch VS2012 New Project: DateAndTimeApp2 Add new item > Web Form: LoadPage2 Double click anywhere outside the “Div” box, to generate the *.vb code file.
  • 51. First attempt When the application is run 1. Output a message: “Time now is xx:xx:xx AM”
  • 52. Libraries provided by Microsoft Before you reinvent the wheel and start to type straight away, look for a suitable one from the libraries provided:
  • 57. output = “Time now is ” & TimeOfDay “Time now is 09:15:36 AM” The combine string is assigned to output Step 1 Step 2
  • 58. Modify App When the application is run 1. Ask user to key in a month from 1 to 12. Eg 1. 2. Output a message: “The month is January.” The month displayed will depends on the input of the user.
  • 63. Exercise: Try to do on your own! When the application is run 1. Ask user to key in a month from 1 to 12. Eg 5. 2. Output a message: “You have key in 5 and the month is May.” The number and month displayed will depends on the input of the user.
  • 64. ASP.NET Visual Basic Web Form Introduction 3
  • 65. Get Started Launch VS2012 New Project: GuessNumber Add new item > Web Form: BtnClick
  • 66. Switch the web form to “Design View”. Then drag the various control from the Toolbox window. finally set their properties using the Properties Window.
  • 67. Page Title Method 1: 1. Switch to source view. 2. Edit <title></title>. Method 2: In Properties window: 1. Select “DOCUMENT” from dropdown. 2. Add/modify “Title” property.
  • 69. This App need to generate a random number for user to guess when the web page is loaded. The same number should remain till the game is over.
  • 73. Get content from Web Control guess = txtAnswer.Text txtAnswer.Text property
  • 74. Set content to Web Control lblResults.text = “Guess correctly.” lblResults.Text property Display updated
  • 75. Decision making and Branching Guess is correct? Yes No “Guess Correctly.” “The hidden number is 8”
  • 76. If … Then … Else … End If If (Guess is correct?) Then output “Guess Correctly.” Else output “The hidden number is 8” End If Flowchart Pseudocode
  • 77. Condition If (Guess is correct?) Then output “Guess Correctly.” Else output “The hidden number is 8” End If
  • 78. Condition Guess is correct? is guess same as hiddenNumber? guess = hiddenNumber Pseudocode Pseudocode VB code
  • 79. VB Code If … Then … Else … End If If guess = hiddenNumber Then lblResults.Text = “Guess Correctly.” Else lblResults.Text =“The hidden number is 8” End If
  • 81. Exercise Modify the App 1. to generate hidden number from 11 to 15 instead of 1 to 10. 2. to clear the txtAnswer.Text after each guess. (Hint: “” => blank)
  • 83. ASP.NET Visual Basic Web Form Introduction 4
  • 84. Get Started Launch VS2012 New Project: ControlStatus Add new item > Web Form: BtnClick
  • 85. 6 Labels Textbox Quick and dirty for proof-of-concept: Use the default names provided - TextBox1, Label1 to Label6, CheckBox1, RadioButton1 to RadioButton2 and Button1
  • 86. The status of each control to be updated on the label next to it
  • 87. The status of each control to be updated on the label next to it
  • 88. Quick and dirty for proof-of- concept: Use the properties from the controls directly without using variables.
  • 89. ASP.NET Visual Basic Web Form Introduction 5
  • 90. Get Started Launch VS2012 New Project: ConvertMonth2 Add new item > Web Form: MonthName
  • 93. Set content: cbPopup.Checked = True OR cbPopup.Checked = False
  • 98. If … Then … End If is cbPopup Checked? Yes Popup: “Month is January” Only need “YES” branch. No need to use “Else” in VB code.
  • 99. HINT: If cbPopup.Checked = True Then …. EndIf
  • 101. Checking for valid input Input is 1? Yes No Process normally Input is 2? Yes No Process normally Flowchart Input is 3? Yes
  • 102. If ... Then … Else If … Then …. Pseudocode If monthNumber = 1 Then Process normally ElseIf monthNumber = 2 Then Process normally ElseIf monthNumber = 3 Then Process normally : End If
  • 104. Subroutines for code reuse Variables declaration moved to outside the subroutine, so that they can be access from all the subroutines including btnConvert_Click() and myFunc(). Common codes are moved into a new subroutine - myFunc().
  • 105. If … ElseIf … Else … EndIf Summary
  • 106. If … ElseIf … Else … EndIf Type 1 If Condition Then Processing End If Type 2 If Condition Then Processing Else Processing End If
  • 107. If … ElseIf … Else … EndIf Type 3 If Condition1 Then Processing ElseIf Condition2 Then Processing End If Type 3++ If Condition1 Then Processing ElseIf Condition2 Then Processing ElseIf Condition3 Then Processing End If
  • 108. If … ElseIf … Else … EndIf Type 4 If Condition1 Then Processing ElseIf Condition2 Then Processing Else Processing End If Type 4++ If Condition1 Then Processing ElseIf Condition2 Then Processing ElseIf Condition3 Then Processing Else Processing End If
  • 109. This is just an introduction. Happy programming!