procedures-deitel

procedures-deitel - CIS 338 VB.NET – Procedures Dr Ralph...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
CIS 338: VB.NET – Procedures Dr. Ralph D. Westfall January, 2009
Background image of page 1

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

View Full DocumentRight Arrow Icon
Classes, Modules & Procedures around 200 classes built into .NET in its Framework Class Library (FCL) similar to Java class library Visual Studio creates a Windows Form class for new applications can also add module(s) to applications modules contain code but aren't classes
Background image of page 2
Three Types of Procedures Subprocedure = code that is used often in different parts of a program like a void method in Java, doesn't return a value may set value(s) elsewhere in program Function is similar to a subprocedure but it returns a value to the segment of code that calls it
Background image of page 3

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

View Full DocumentRight Arrow Icon
Subprocedure (Subroutine) Sub [name]([ByRef or ByVal] [args as types]) '0 to many args after [name] ' parameter list = all of args '[1 or more lines of code to run: 'statements and probably declarations] End Sub
Background image of page 4
Subprocedure - 2 can be called (run) in two ways Call [name (args)] 'OR [name (args)] 'the word Call is optional (but I like it) each arg must match data type and be in same order as in Sub's "header line" Sub runs and then execution returns to next statement after line where it was called
Background image of page 5

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

View Full DocumentRight Arrow Icon
Subprocedure - 3 Sub CopyRightInfo(ByVal nYear as _ Integer) " © End Sub [lines of code] Call CopyRightInfo (2001) [lines of code] CopyRightInfo(1999)
Background image of page 6
Function built in functions are used frequently by programmers e.g., Dim age as Integer age = CInt(txtName.Text) can code your own functions after you code them, they work in exactly the same way
Background image of page 7

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

View Full DocumentRight Arrow Icon
Programmer Created Function very similar to a subprocedure, except first and last lines have End Function instead of End Sub returns a value, so need to specify a data type at end of very first line and returned value must match it need to have a Return statement or a variable with same name as last line before End statement
Background image of page 8
Function - 2 Function [fName]([args] as [types]) As [type]) ' can include argument(s) after [fName] ' argument(s) & function have data types ' declarations '[1 or more lines of code to run] Return [some value or calculation] 'OR '[fName] = [some value or calculation] End Function
Background image of page 9

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

View Full DocumentRight Arrow Icon
Function - 3 Function SevenX(ByVal i as Integer)
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/13/2009 for the course CIS 338 taught by Professor Westfall during the Winter '09 term at Cal Poly Pomona.

Page1 / 34

procedures-deitel - CIS 338 VB.NET – Procedures Dr Ralph...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online