Sunday 23 March 2014

What Is Procedure In Visual Basic?

Procedure In Visual Basic?




Procedure:


The basic procedure are small and self-contained segments of code, which are useful for implementing the repeated task. A program, which calls the procedure is called calling program. Procedure in Visual Basic are classified into following groups.




Subroutines:


Subroutines are that type of procedure, which returns no result to the main program through which it is called. All statements of subroutines are placed within pair of Sub/End Sub statements. Subroutines are called by its name through Call statement. Syntax of Subroutines declaration is as under.

          Sub SubroutineName ([arguments])
                 Statement(s)
         [Exit Sub]
                  Statement(s)
          End Sub

Where End Sub Statement is used to send control back to main program after execution of all statements of subroutine and Exit Sub statement can be used anywhere in subroutine to send control back to main program. Subroutine name must be meaningful and not a keyword. Subroutine may have zero, one or more than one arguments.


Event Handlers:


Every application of Visual Basic contains a number of event handlers. An event handlers is like a subroutine and can be executed each time when an external condition occurs. e.g.

          Private Sub Command1_Click()
                    Statement(s)
          End Sub

This Event handler is executed when button is clicked. Unlike subroutines, Event handlers do not trnsfer control back to main program because it is called independently.


Functions:


Functions are that type of procedures, which must return a result to the calling program. All statements of a function are placed within pair of Function / End Function statements. Syntax of Function declaration declaration is.

       Function FunctionName (]arguments])[AS Data Type]
               Statement(s)
       End Function

Where Function name must be a meaningful, and not a keyword. Number of arguments in function may be zero, one or more than one. If a Function has no return Data Type then default will be Variant.



Me : If you need more help, want to ask feel free to use below comment box. It will be my pleasure to help you. THANKS for reading.

 
Search Engine Submission - AddMe url submit Casino us org Seo Packages http://blogsiteslist.com