Elipse Knowledgebase



Basic VBScript for Elipse E3: Lesson 10 - Procedures and Functions

Procedures are code lines, used to respond to events and execute actions. Procedures do not return values and are identified by the Word Sub in their declaration. All procedures must start with a letter, and can contain letters, numbers and underscore character.

Functions are used to execute calculations and test values, and always return something. An example would be to sum two values and return the value of the sum.

Example:

Sub CommandButton1_Click()
    'Function add
    answer = Add(10,20)
    MsgBox answer
   
    'Sub display message
    DisplayMessage("Message to be displayed")       
End Sub

Function Sum(a,b)
    Sum = a + b
End Function
   
Sub DisplayMessage(message)   
    MsgBox menssage
End Sub

Exercises:

1. Create a button that contains a Function that adds, multiplies and divides two numbers and displays each answer on a message box.
2. Create the following alarm structure:
 

Figure 17

3. Link each digital alarm to an internal tag. To change the value of the internal tag, use ToogleButton on screen.
4. Create a button that displays a message box for all alarm objects. The message must inform whether it is an area or a digital alarm, and the name of the object. Tip: for each object, check the Typename. Create a Sub for area type objects and another Sub for source type objects.



Related Articles

Attachments

Visitor Comments

No visitor comments posted. Post a comment

Post Comment for "Basic VBScript for Elipse E3: Lesson 10 - Procedures and Functions"

To post a comment for this article, simply complete the form below. Fields marked with an asterisk are required.

   Name:
   Email:
* Comment:
* Enter the code below:

 

Article Details

Last Updated
28th of October, 2009

Autor
Paula Pereira Enéas

Would you like to...

Print this page  Print this page

Email this page  Email this page

Post a comment  Post a comment

 Subscribe me

Subscribe me  Add to favorites

Remove Highlighting Remove Highlighting

Edit this Article

Quick Edit

Export to PDF


User Opinions

No users have voted.

How would you rate this answer?




Thank you for rating this answer.

Continue