An intro to subroutines
Sub DisplayName()
Dim FirstName As String = "Josh"
Dim LastName As String = "Waxman"
Dim FullName as String
FullName = FirstName & " " & LastName
MsgBox FullName
End Sub
Private Sub Button1_Click(...) Handles ...
DisplayName
End Sub
Private Sub Button2_Click(...) Handles ...
DisplayName
End Sub
----
Private Sub Button1_Click(...) Handles btnAdd.Click
'Display the sum of two numbers
DisplayOpeningMessage
DisplaySum(2, 3)
End Sub
Sub DisplayOpeningMessage()
lstResult.Items.Clear()
lstResult.Items.Add("This program displays a sentence")
lstResult.Items.Add("identifying two numbers and their sum.")
lstResult.Items.Add("")
End Sub
Sub DisplaySum(num1 As Double, num2 As Double)
lstResult.Items.Add("The sum of " & num1 & " and " _
& num2 & " is " & num1 + num2 & ".")
End Sub
formal parameters
as opposed to actual parameters
we COPY the actual parameters into the formal parameters
' Get Input
' Processing
' Output Results
top-down design
stepwise refinement
stack
FILO (first in, last out)
push operation (put onto top of stack)
pop operation (taking off top of stack)
call stack
stack frames
use this to understand firstpart, secondpart example
No comments:
Post a Comment