1 / 11

Function &Procedure

Function &Procedure. Procedures. Visual Basic offers different types of procedures to execute small sections of coding in applications. The various procedures are elucidated in details in this section. Visual Basic programs can be broken into smaller logical components called Procedures.

erbe
Download Presentation

Function &Procedure

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Function &Procedure

  2. Procedures • Visual Basic offers different types of procedures to execute small sections of coding in applications. • The various procedures are elucidated in details in this section. Visual Basic programs can be broken into smaller logical components called Procedures. • Procedures are useful for condensing repeated operations such as the frequently used calculations, text and control manipulation etc.

  3. Sub Procedures • A sub procedure can be placed in standard, class and form modules. Each time the procedure is called, the statements between Sub and End Sub are executed. The syntax for a sub procedure is as follows: • [Private | Public] [Static] Sub Procedurename [( arglist)] • [ statements] • End Sub

  4. Event Procedures • An event procedure is a procedure block that contains the control's actual name, an underscore(_), and the event name. The following syntax represents the event procedure for a Form_Load event. • Private Sub Form_Load() ....statement block.. End Sub

  5. Function Procedures • Functions are like sub procedures, except they return a value to the calling procedure. • They are especially useful for taking one or more pieces of data, called arguments and performing some tasks with them. • Then the functions returns a value that indicates the results of the tasks complete within the function. • The following function procedure calculates the third side or hypotenuse of a right triangle, where A and B are the other two sides. • It takes two arguments A and B (of data type Double) and finally returns the results.

  6. Property Procedures • A property procedure is used to create and manipulate custom properties. It is used to create read only properties for Forms, Standard modules and Class modules. • Visual Basic provides three kind of property procedures-Property Let procedure that sets the value of a property, Property Get procedure that returns the value of a property, and Property Set procedure that sets the references to an object.

  7. Control Statements: • Control Statements are used to control the flow of program's execution. • Visual Basic supports control structures such as if... Then, if...Then ...Else, Select...Case. • Loop structures such as Do While...Loop, While...Wend, For...Next…

  8. If...Then selection • If...Then selection structure: • The If...Then selection structure performs an indicated action only when the condition is True; otherwise the action is skipped. Syntax of the If...Then selection If <condition> Then statement End If

  9. If...Then...Else selection structure: • The If...Then...Else selection structure allows the programmer to specify that a different action is to be performed when the condition is True than when the condition is False. Syntax of the If...Then...Else selection If <condition > Then statements Else statements End If

  10. Select...Case selection structure: • Select...Case structure is an alternative to If...Then...ElseIf for selectively executing a single block of statements from among multiple block of statements.

  11. LOOPS (REPETITION STRUCTURES): • The For...Next Loop: • ` The For...Next Loop is another way to make loops in Visual Basic. For...Next repetition structure handles all the details of counter-controlled repetition. The following loop counts the numbers from 1 to 100: Dim x As Integer For x = 1 To 50 Print x Next

More Related