REVISION of chapter 10 Targets Revision of functions
- Slides: 17
REVISION of chapter 10
Targets Revision of functions Revision of subroutines
Functions Declaration Function Name ( [arguments ] ) As function type Function statements End Function
Functions Usually we use the functions for mathematical operations procedures We call the function by its name in the main Program Functions can pass arguments and it must return values in its name
Sub Declaration Sub procedurename([arguments]) Procedures ststements End sub
Sub We call the subroutine by its name in the main Program subroutine can pass arguments and it may return values
Example 1 • • • • • Function tax(By. Val cost As Single) As Single Dim sals As Single sals = cost * 5 / 100 Return sals End Function Sub n() Select Case tax(500) Case Is >= 500 : Text. Box 1. Text = " ﺷﺮﻳﺤﺔ 3" Case Is >= 300 : Text. Box 1. Text = " ﺷﺮﻳﺤﺔ 2" Case Is >= 100 : Text. Box 1. Text = " ﺷﺮﻳﺤﺔ 1" Case Else : Text. Box 1. Text = " "ﻣﻌﻔﻰ ﻣﻦ ﺍﻟﻀﺮﻳﺒﻪ End Select End Sub Private Sub Button 1_Click(By. Val sender As System. Object. . n() End Sub …………………………………………………………………………………………………………………………………………………… …
Example 2 • • • Private Sub Button 1_Click(By. Val sender………… Dim intcount As Integer = 5 Zero. Out(intcount) End Sub Zero. Out(By. Val int. Arg As Integer) Dim b As Integer = 6 b += int. Arg Msg. Box(b) End Sub …………………………………………………………………………………………………………………………… …………………………………………………
Example 3 Private Sub Button 1_Click(By. Val sender As System. Object, By. Val e As System. Event. Args) Handles Button 1. Click cost(40) End Sub cost(By. Val num As Integer) textbox 1. text = num & "ryals" End Sub. . . . ﻣﺤﺘﻮﻯ ﺻﻨﺪﻭﻕ ﺍﻟﻨﺺ ﻫﻮ
Example 4 134 - Private Sub Button 1_Click(By. Val sender As System. Object, By. Val e As System. Event. Args) Handles Button 1. Click sum(3, 5, 6) End Sub sum 1(By. Val a As Integer, By. Val c As Integer, By. Val b As Integer ) Text. Box 1. Text = a + b + c End Sub. . . . ﻣﺤﺘﻮﻯ ﺻﻨﺪﻭﻕ ﺍﻟﻨﺺ ﻫﻮ
Example 5 - function compute. Area(By. Val length As Double, By. Val width As Double) Dim area As Double If length = 0 Or width = 0 Then Exit Sub area = length * width return area End Sub Private Sub Button 2_Click(By. Val sender As …… Text. Box 1. Text = compute. Area(0, 3) End Sub. . . . ﻣﺤﺘﻮﻯ ﺻﻨﺪﻭﻕ ﺍﻟﻨﺺ ﻫﻮ
Example 5 choose the correct declaration of the procedure that we can call in the following way : – Sum(9, 5) 1 -Function sum() as double 2 -Function sub(byval x as single , byval y as single) 3 - Function sum(byval x as single , byval y as single) 4 -Function sum(byval x , y as single)
Example 6 choose the correct declaration of the procedure that we can call in the following way : Msg("omr", 3, 5) 1 -sub msg() as double 2 -sub msg(byval x as single , byval y as single, byval z as string) 3 -sub msg(byval x as string , byval y as single, byval z as integer) 4 -sub msg(byval x as string , byval y as single, byval z as integer) as string
Example 7 • Find the mistakes in the following programming sentences Private Sub Button 2_Click(By. Val sender As…. . Msg. Box = (sum(2, 7)) End Sub Function mark(By. Val num 1 As Integer, By. Val num 2 As Integer)As Integer Select Case num 1 + num 2 Case Is > 50 : Return "pass" Case Else : Return "fail" End Select End Function …………………………………………………………………………………………………………………………………………………… ………………………………………………………………………
Example 8 Find the mistakes in the following programming sentences Private Sub Button 2_Click(By. Val sender As System. Object…… birth(18, "mona aly") End Sub birth(By. Val person As String, By. Val age As Single) Dim msg As String = " your name is " Dim msg 1 As String = "and your age is" Msg. Box(msg & person & msg 1 & age) End Sub ………………………………………………………………………………………………………………………………… ……………………………………………
- Identifying market segments and targets chapter 9
- Identifying market segments and targets chapter 9
- Identifying market segments and targets chapter 9
- Passive revision
- Objectives of warehousing
- Writing learning targets
- Jim crow laws in what region or regions did it exist
- Brides magazine targets consumers who are in
- Targets of change
- Smart pe gcse
- Agonist antagonist muscles
- Final sketch crime scene
- Product learning target example
- Learning targets knowledge, reasoning, skill product
- Nyseslat performance level descriptions
- Learning targets helping students aim for understanding
- A firm that uses blank segmentation divides
- Early childhood education barbados