Course visual basic : functions

Course visual basic : functions













Course visual basic : functions

















Functions are similar to normal procedures but the main purpose of the functions is to accept certain inputs and pass them on to the main program to finish the execution. They are two types of function, the built-in functions(or internal functions) and the functions created by the programmers.

The general format of a function is

functionName(arguments)

 where arguments are values that are passed on to the functions.

In this lesson, we are going to learn two very basic but useful internal functions, the MsgBox( ) and InputBox ( ) functions.

MsgBox ( ) Function

The objective of MsgBox is to produce a pop-up message box and prompt the user to click on a command button before he /she can continues. This message box format is as follows:

 yourMsg=MsgBox(Prompt, Style Value, Title)

The first argument, Prompt, will display the message in the message box. The Style Value will determine what type of command buttons appear on the message box, please refer Table 10.1 for types of command button displayed. The Title argument will display the title of the message board. 

The InputBox( ) Function

An InputBox( ) function will display a message box where the user can enter a value or a message in the form of text. The format is

myMessage=InputBox(Prompt, Title, default_text, x-position, y-position)

Prompt      - The message displayed normally as a question asked.
Title           - The title of the Input Box.
default-text - The default text that appears in the input field where users can use it as his intended input or he may change to the message he wish to key in.
x-position and y-position - the position or the coordinate of the input box.

The procedure for the 3rd button......







Download Course visual basic : functions











Course visual basic : functions

1 commentaire: