Week 7 WS - GEOCITIES.ws

Download Report

Transcript Week 7 WS - GEOCITIES.ws

Name ______________ No _____ Class _______
(PA)
Revision Exercise: Control
Which control will you use to display your name?
____________
Which control will you use to get user’s click action?
____________
Which control will you use for user to choose the kinds of fruit
he/she likes, e.g. Apple, Banana, Orange?
____________
Name ______________ No _____ Class _______
(PA)
Revision Exercise: Concatenation
txtFirstName
txtLastName
Peter
Chan
txtResult
Write code to join the text string so that txtResult will look like as
below?
txtResult
My Name is Peter Chan.
txtResult.text = “My Name is ”
Name ______________ No _____ Class _______
(PA)
Revision Exercise: Symbol
Which symbol is used to enclose a text string in code, e.g.
“Hello World” and then assign it to a textbox?
____________
Which symbol can be used to write a non-executable
comment?
____________
Which symbol will you use to break a long statement into
different lines?
____________
Name ______________ No _____ Class _______
Revision Exercise: Code
txtName
1. Write code to assign “Peter” into a textbox?
txtName
Peter
=
2. Write code to end a program?
3. Write code to reset the insertion point in a textbox?
(PA)
Name ______________ No _____ Class _______
(PA)
Exercise
n = 4, answ = “Y” Are the following
True/False
conditions true or false?
Not (n < 6)
(answ = "Y") Or (answ = "y")
(answ = "Y") And (answ = "y")
Not(answ = "y")
Name ______________ No _____ Class _______
(PA)
Exercise
Determine whether the following conditions
are true or false.
Let a = 2, b = 3
1.
(5 – a) * b < 7
2.
NOT (a < b)
3.
(a * a < b) OR NOT (a * a < a)
True/False
Name ______________ No _____ Class _______
(PA)
Exercise
Determine whether the following conditions are
true or false.
Let a = 2, b = 3
True/False
1.
“Inspector” < “gadget”
2.
a <> b
3.
((a=b) OR NOT (b < a)) AND ((a < b) OR (b = a + 1))
Name ______________ No _____ Class _______
(PA)
Exercise: Find the larger number (1)
This application is used to find a bigger number.
After you have entered 2 numbers into the first two textboxes and have clicked the button,
the bigger number will then be displayed in the last textbox.
In VS.NET 2003, which area should you double click and put the code inside?
1
2
3
4
5
6
Name ______________ No _____ Class _______
(PA)
• In VS.NET 2003, which area should you put the code inside?
7
Line 3
8
Line 4-123
Don’t change!
2
1
3
4
5
9
6
Line 144
Name ______________ No _____ Class _______
(PA)
Exercise: Find the larger number (3)
Fill in the blanks:
Hints: Label1, Label1.text, txtNum1, txtNum1.Text, txtNum2, txtNum2.Text,
txtResult, txtResult.Text, num1, num2, largerNum, CInt, CDec, Interger,
Double, Decimal, Date
Dim num1, num2, largerNum As ____________
num1 = CDec(____________)
num2 = CDec(txtNum2.Text)
If num1 > num2 Then
_________ = num1
Else
largerNum = ______
End If
txtResult.Text = _The larger number is " __ __________
txtNum1
txtNum2
txtResult
Name ______________ No _____ Class _______
Exercise:
Determine what output will be displayed in the text box when
the button is clicked.
Private Sub btnDisplay_Click (…) Handles btnDisplay.Click
Dim gpa As Double = 3.49
txtOutput.Clear()
If gpa >=3.5 Then
txtOutput.Text = “Good”
End If
txtOutput.Text = txtOutput.Text & “ Student”
End Sub
What is the output result of the text box?
(PA)
Name ______________ No _____ Class _______
(PA)
Compound Conditions
If radMale.Checked = True And CInt(txtAge.Text) < 21 Then
… ‘Will the program continue to run
…
End If
Situation
radMale not checked
txtAge greater than 21
radMale not checked, txtAge less than 21
radMale checked, txtAge 21 or greater
radMale checked, txtAge less than 21
True/False
Name ______________ No _____ Class _______
(PA)
Compound Conditions
If radJunior.Checked = True Or radSenior.Checked = True Then
… ’Will the program continue to run
…
End If
Situation
radJunior.Value=True
radSenior.Value=True
radJunior.Value=False, radSenior.Value=True
radJunior.Value=True, radSenior.Value=False
radJunior.Value=False, radSenior.Value=False
True/False