Lecture 16 - File In Out

# Lecture 16 - File In Out - Functions and Subroutines Review...

This preview shows pages 1–4. Sign up to view the full content.

Functions and Subroutines: Review How will learning this help me? • Functions built into your programs enable you to tailor programs to your needs. • Subroutines are mini-programs within larger programs— they enable you to keep complex parts of your program separate from other parts. Engr 160

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Important Observations Functions Returns one value Don’t forget to use the name of the function By Val: don’t change the value in the function By Ref: change the value in the function Subroutines • Number of arguments in call statement must match (in number, type, and order) the number of arguments in the subroutine • Call Resultant( Fx , Fy , Fr , Angle ) • Sub Resultant( a As Single , b As Single , c As Single , d As Single ) Engr 160
Engr 160 Sub sample_subroutine() 'This program demonstrates the use of subroutines 'Fx is the x component of a force 'Fy is the y component of a force 'Fr is the resultant force 'angle is the angle of the force in degrees Dim Fx As Single, Fy As Single, Fr As Single, Angle As Single Fx = InputBox("Input the x component of the force") Fy = InputBox("Input the y component of the force") Call Resultant(Fx, Fy, Fr, Angle ) Angle = Rtd(Angle) End Sub Sub Resultant(ByVal a As Single, ByVal b As Single, ByRef c As Single, ByRef d As Single)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 15

Lecture 16 - File In Out - Functions and Subroutines Review...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online