- In the computer code, you can identify functions in two ways. First, there should be comments above the block of code that would start with an apostrophe symbol letting the computer program know that the comments that follow after are not included in the program. For example, you would see: 'This function processes the addition of two numbers entered by the user.'
Second, you will notice it by the way the syntax is structured. It begins with the phrase 'Public (or Private) Function' and ends with the phrase 'End Function.' The word "function" can be substituted for the name of the function. All of the code in between these two statements makes up the function. - Many often-used functions in Visual Basic are already loaded into the tools computer programmers use to create software. For example, a programmer wants to be able to allow the user to press a button that would give the square root of a number. The programmer would use the 'Sqr' function to do this. It is not necessary for the programmer to invent a function to do this, as it is already pre-loaded for the programmer to pick and use.
- Sometimes the programmer needs to create a function that doesn't yet exist to get the correct results that are sought. While following the necessary syntax of Visual Basic, the programmer would type: 'Public(or Private) FunctionName' and type the necessary code to perform the calculation, then end it with 'End FunctionName.'
- Functions are also used when comparing items input by the user to items stored in a database such as username and passwords. The software displays a place for the user to input the username and password and the functions 'Equals' and 'compareTo' are used to see if the username and passwords match what is in the database.
- The 'MsgBox' function displays calculation results to users under certain conditions and can be customized with any messages you wish. For example, a typical message box that pops up is a confirming one stating something similar to "You are about to navigate from this page. Are you sure you want to continue?" Then you have a choice between an 'OK' and a 'Cancel' button. When the user makes their choice between the two buttons, the code is performing yet another comparison-type function so that it may know which task to proceed with.
Identification
Predefined
Custom
Authentication
Displaying
SHARE