This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Function Square (ByVal input As Double ) As Double Name parameter list return type (Function will “return” a Double) ByVal means “sending a copy” parameter type Return input * input End Function Elsewhere in code (anywhere in class) Dim x As Double = 5.0 Dim y As Double Y = Square (x)-------procedure call execution is transferred to body of function, then jumps back Y gets return value One argument for each parameter Function Divide (ByVal x As Double, ByVal y As Double) As Double Return x/y End Function-------Subroutines (Sub) work like functions but don’t return a value All of the event handlers are subroutines When do I need subroutine? • code is too long • processing done more than once---procedure should have one clearly-defined task...
View Full Document
- Fall '10
- Subroutine, Foundation Class Library