The stored procedure can have the dynamic sql statement for the complex decision making operations which generated inside the stored procedures. Pascal encourages modular programming, where a program is created from a number of smaller and simpler pieces known as modules. These functions are pretty much similar to other VBA Excel functions like UserRange. Net, the Timer is a component which is added to the tray at the time of design. In Excel Visual Basic, a set of commands to perform a specific task is placed into a procedure, which can be a Function procedure or a Sub procedure (also known as functions and subroutines). We often use Subs and Functions often not thinking. Function Procedure - A Function procedure is a series of Visual Basic statements enclosed by the Function and End Function statements. First, let's cover the definition of these two keywords as they are presented in the Visual Basic documentation. This means that the line that calls one Sub can pass values to another Sub. The performance issue has ZILCH to do with it. Create simple solutions to complex problems by levering Excel functionality with Macros. A function procedure is a series of VBScript statements enclosed by the Function and End Function statements. Sub todayDay(). The example defines a procedure called Test that contains code that can be accessed from any point in the program. This is not a good way to write your code. The menu equivalents are Visual Basic functions that execute the Hyperion menu commands. I have logic which has to be repeated many times over and instead of recoding them twenty times I am hoping to put them into procedures and functions and then pass them arguments and get return values out. How to return multiple values from a VBA function (Part 2) Part 2 - Using array, CSV, and user-defined type. To get time difference you need to use TimeSpan object, with code like this: TimeSpan ts = DateTime1 - DateTime2; For example, if you want to calculate time difference between server time and UTC time: [ C# ] protected void Page_Load(object sender, EventArgs e) {. Modules and Procedures and Their Scope. Explain the differences between a function and a sub procedure. In the calling procedure the data entered in the userform is returned using a simple VBA MsgBox function. Worksheets in VBA Coding and in Worksheet Formulas (this page -- sheets. Call a Sub procedure by using the procedure name followed by the argument list. NET) This snippet will execute a process at the location specified by ProcessPath synchronously -- i. 2 DISCARDING SELECTED KEYSTROKES IN THE KEYPRESS EVENT PROCEDURE. It can be executed using the sp_executesql statement. The Function version does it by assigning the new value to the name of the function while the Sub version assigns it to the name of one of the arguments. For all general questions relating to Excel but not including VBA or formulas. The Sub procedure in the tags is an event procedure. While in Visual Basic. There is a difference between how we used the MsgBox function earlier and the way we are using InputBox in this example. The difference between Functions and Subs First, though, in case you are wondering what the difference is between a Function and a Sub, it's this: Functions return a value, and Subs don't. The 2 most common types of procedures in Visual Basic for Applications are Sub procedures and Function procedures. Your macros should include Option Explicit, Dim, InputBox, MsgBox, titles on the dialog boxes, an icon on the message box, and use appropriate data types for your variables. Visual Basic Access gives you lots versatility when it comes to loops. ByRef passes a pointer to the variable, so any changes are reflected everywhere that variable is used. Example1 (value) Console. A Function procedure returns a value and a Sub Procedure does not return a value. End Sub ''' ''' Button two on a form to show that the event handler of another button can be called. The example defines a procedure called Test that contains code that can be accessed from any point in the program. A constructor is a special type of subroutine called at the creation of an object. Here is an example:. Rather than repeating the same operations at several different places in the program, they can be placed in a procedure or function. Copy SQL statement from query to VBA Rather than typing complex query statements into VBA code, developers often mock up a query graphically, switch it to SQL View, copy, and paste into VBA. Here is an example:. Custom functions will appear in this list if their script includes a JsDoc @customfunction tag, as in the DOUBLE() example below. NET AddHandler and RemoveHandler statements allow this behavior. ByRef is the alternative. But the function cannot execute the sp_executesql statement. A function procedure is similar to a sub procedure but it can return value to the calling function. Code vs Sheet vs ThisWorkbook Module. What is the difference between a procedure and a function in Visual Basic? A procedure is a snippit of code that is a specific list on instructions that a program may execute once or twice. Hope this helps you. Example Sub Area(x As Double, y As Double) MsgBox x * y End Sub Calling Procedures. What is the difference between a sub and a function? They are both procedures, but a function returns a value and a sub does not. The DLL functions do some manipulation with the arrays, and pass them back to VBA where they are then printed out. Otherwise it returns the character position where the text is found. Write a program that asks any three numbers and displays the difference between the greatest and the smallest value among the 3 supplied numbers using FUNCTION procedure. Format (n, "style argument"). Why Not Use Byref:. Microsoft Support site or the Excel VBA Help section on your computer contains comprehensive examples on most the issues covered on this page. For Best Practices, each procedure should end at its bottom. Procedure: In computer programming, a procedure is an independent code module that fulfills some concrete task and is referenced within a larger body of source code. ProductSubcategory" Return connection. Execution continues with the statement following the statement that called the Function.  Properties defined through public variables are simple to use. There are no built-in functions in C++. Calling sub and function from static class in vb. Module-level variables can be declared with a Dim or Private statement at the top of the module above the first procedure definition. Last time, we looked at arrays, and as promised, this week we'll check out functions and sub procedures. How to use. A procedure is a set of code that does the work but does not return a value whereas a function accepts parameters and does the calculation and does return a value back. The Sub procedure performs a task and then returns control to the calling code, but it does not return a value to the calling code. One to declare the variable, and one to assign the file name to the variable. Basically a proced ure will only run once everytime it's action is called. The technology was developed originally to interface with any data source, not just SQL. Chapter 5 Object Orientation in C# and Visual Basic. NET to create and to call a Microsoft SQL Server stored procedure with an input parameter and an output parameter. A sub-procedure does not return a value while a function returns a value. Since it's a nuanced question, the answer is targeted at those who already have an intermediate-level background in computer science and pr. When you click the button, Internet Explorer makes the connection between the button and the code, and runs the procedure. A sub procedure does not. In this article, I will explain you how to use of Constructors and Destructors in Visual Basic. The confusing part is when people use these terms, they're not always referring to the pure definitions. A VBA Function can accept parameters and return results. The difference between the two is that a function can return a value while a procedure does not. For those of you who have already made the leap to object-oriented programming, you know how difficult the transition can be. How do I construct an SQL statement in VBA? Constructing an SQL statement in VBA can be tricky, because there are often several areas of Access needed to construct the string. Procedures in Excel VBA – What is a Sub Procedure? A sub procedure in VBA is a procedure that performs a specific task. A constructor is a special type of subroutine called at the creation of an object. For example, proper SQL syntax, proper VBA syntax, and proper referencing of controls are three common points. I need to take three elements and create a sha1 signature from it to add as &authSignature=New Project->Visual Basic->WPF Application. There are no built-in functions in C++. • Functions (…this is the one I'll talk about …) Called as part of a select, insert, update, etc. A property is not analagous to a Java field, it executes a class procedure just as a method does. Other languages do other things. This is part 2 of the article series - 8 ways to return multiple values from a VBA function. A function refers to a subroutine that allows the execution of a set of instructions by simply calling in the body of the main program. The sample Access database files from Microsoft website have many useful commands or functions under the Embedded Macro. VB Function vs Sub procedure vs Gosub I think I understand what the purpose of each of the above is. The function version can be used in an expression as follows:. NET, Application, AddSeconds, DoEvents, Thread, Pause, and 10 Seconds. Reverse String Search Function in VBA: InStrRev. rdlc will show the Department table details and contains a sub report component with REPORT2. A procedure is a set of code that does the work but does not return a value whereas a function accepts parameters and does the calculation and does return a value back. UDFs must begin with Function keyword, followed by function name and then define parameter with in parentheses (), followed by As keyword and functions's data type and end funtion with End Function. Creating a function entails having a return statement in it and it is called as a part of an expression. A Function is a procedure that returns a value while a Sub performs its task without returning a value. Aside from Private and Public, you may also declare a Subroutine as Static. ByVal or ByRef - what's the difference? Posted on March 10, 2016 by Rory Archibald This is a question I see increasingly frequently in forums for some reason, so I thought I'd cobble together a brief synopsis. Passing Arguments to Subroutines and Functions. Msgbox is also a function, as is InputBox is this example. NET really are parts of existing code: programmers with experience in both worlds are required to effectively target the new platform with. This is short for By. The following are examples of possible procedures: Sub Function Event Handling Property Get/Set Procedures Operator Procedures Generic. VB (visual BASIC) is a language for programs creators whereas VBA (visual BASIC for application) is a language for applications creators (Excel, Access, etc. Sub procedure. Below is a function that returns the name of the. Of course if you know the stored procedure returns complete entities you can specify that in the function mapping dialogbox and if there is already a complext type that matches the stored procedure result you can select the complext type, but you do not need to create neither an entity nor a complex type before importing and mapping the stored. The advantages of using procedures and functions are: Reducing duplication of code; Decomposing complex problems into simpler pieces; Improving clarity of the code; Reuse of code; Information hiding; Procedures. Explicit definition of a namespace is done in VB. Visual Basic is an (OO) object-oriented language. In Ada there is a clear distinction betwen FUNCTIONS and SUBROUTINES. 2) OUT type parameter: These types of parameters are used to get values from stored procedures. The difference between the two is that a function can return a value while a procedure does not. I had my wife and kids playing with it for quite a while! Try adding a frame or MouseWheel while a cartoon is playing. Once Inside the Worksheet Change Event, if the Target falls within the defined Range and the cell contents change, it will trigger an action inside VBA. Chapter 4 Introduction to Visual Basic. Let's take a look at some of the differences between the two and when they should be used. Say even if we've 100 procedure's in a package, its not going tough in debugging or to modify a procedure in it ,because every procedure(or function) will be a separate subroutine in the package. I would like to know if there is a way to create functions and procedures in C# same as in VBA. Constructors. Assuming you want to capture the filename of the workbook currently open I would add two lines of code. Once VBA has executed all the code for the second sub it returns to where it was. For Best Practices, each procedure should end at its bottom. Version End Function. Function will return a value to the caller while Sub just execute the code without returning value. Place a function into a module. We can use in a function/sub in the class module e. Sub Master() SalesData = GetInput("Enter Sales Data") If SalesData = False Then Exit Sub PostInput SalesData, "B3" End Sub Function GetInput(Message) Data = InputBox(Message) If Data = "" Then GetInput = False Else GetInput = Data End Function Sub PostInput(InputData, Target) Range(Target). This kind of code item can also be called a function or a sub-routine. They are just like Sub procedures except that they can return a value. I most often use the Sleep function (system32. End Sub End Module Module Module2 Private Function Function1() As String Return "Hello from Visual Basic" End Function End Module Namespace Scope If you declare an element at module level using the Friend or Public statement, it becomes available to all procedures throughout the entire namespace in which it is declared. Calling Sub Procedures and Function Procedures. To make the program start by running Sub Main, follow these steps: Create a new Windows Forms project. When to put VBA code in worksheet versus module As someone who is relatively new to VBA, can someone tell me the rule(s)/guideline(s) for putting VBA code in a worksheet versus putting it in a module?. The Function procedure performs a task and then returns control to the calling code. The function version can be used in an expression as follows:. You can execute Function procedures and call the function in Excel 2016. ByVal or ByRef - what's the difference? Posted on March 10, 2016 by Rory Archibald This is a question I see increasingly frequently in forums for some reason, so I thought I'd cobble together a brief synopsis. but sub does not return any thing. In POP, there is no specific accessing mode to access attributes or functions in the program. Public Function Square(dbl As Double) As Double Function procedure. So how can you call a Private Sub or Function? Or is that simply not possible? I have an OnTime event that needs to call another Sub when the timer runs out, but that other Sub is private. In this VBA tutorial, I focus on VBA Sub procedures. FindFirst "[ID] = " & str(ID). However, you might have trouble moving information from the VBA procedure to the form, or retrieving information when the user has finished with the form. This type of procedure is useful if you want to call the code in response to two or more events, such as clicking a button or choosing a menu item. The VBA Instr Function checks if a string of text is found in another string of text. Since Word 2003 there have been made some changes to the fact on what kind of SQL one can use within the field DATABASE. These functions are pretty much similar to other VBA Excel functions like UserRange. How to use. You can pass arguments to a procedure (function or sub) by reference or by value. A function is normally called as a part of an expression. What is the difference between a sub and a function? They are both procedures, but a function returns a value and a sub does not. The stored procedure can have the dynamic sql statement for the complex decision making operations which generated inside the stored procedures. Sub is the Visual Basic keyword which indicates this is a Subroutine rather than a Function. Difference between function and stored procedure in Oracle with examples Functions and stored procedures are set of SQL statements that can be called by name. Calling sub and function from static class in vb. The 2 most common types of procedures in Visual Basic for Applications are Sub procedures and Function procedures. This is part 2 of the article series - 8 ways to return multiple values from a VBA function. For example, in Sub Procedure1, you have declared variableA = 1. L'appel d'une Sub ou d'une fonction ne se fait pas tout à fait de la même façon. You declare a function in much the same way as a Sub procedure, except that you use the Function keyword instead of Sub. If you want to execute a series of statements without returning any value, then you can use sub procedures. 7 Date and Time Functions This section describes the functions that can be used to manipulate temporal values. The stored procedure can have the dynamic sql statement for the complex decision making operations which generated inside the stored procedures. In function we can return values as boolean, string and other data data types. Place a function into a module. Difference between Function and Stored Procedure in Single Line of Word—— Function can not changes our Database State but Stored Procedure Can do Anything. Each module can contain a. Difference between function and stored procedure in Oracle with examples Functions and stored procedures are set of SQL statements that can be called by name. Difference between procedures and functions • When the parameter is passed into the procedure; it does not return any value whereas a function always returns a value. Passing an Array to and from a Function or Subprocedure in VB6 End Sub This code should look familiar to you--it's similar to the code from last month's article where I described how to use the For…Each statement to loop through the elements of an Array. How do I construct an SQL statement in VBA? Constructing an SQL statement in VBA can be tricky, because there are often several areas of Access needed to construct the string. NET, Subs and Functions contain behavior. We also saw that the main difference between a sub procedure and a function is that a function can return a value but a sub procedure cannot. NET with specifications Namespace and End Namespace. 75, fries for $2. The call is made by entering the procedure name at the relevant point of the program. Therefore, if you wish to perform a task that returns a result (e. All the data are based on the parameters that we choose in the ASP. You can even learn a lot more about VBA if you want. A Function procedure is similar to a Sub procedure, but a function can also return a value. You can also specify arguments (brackets) for Subroutines too. You can call stored procedures or functions from a database trigger, another stored subprogram, or interactively from SQL Command Line (SQL*Plus). ByRef is the alternative. 1) IN type parameter: These types of parameters are used to send values to stored procedures. Answer / aftab. A Function procedure is one that returns a value after performing its assigned task. (Note that returning an array as the result of a function or property was added in Office 2000 -- functions in Office 97 cannot return arrays. Here are a few examples of using VBA functions in code. Note 2:We can use the word procedure to refer to a function or sub. Public Function Square(dbl As Double) As Double Function procedure. Only functions and some extended stored procedures can be executed from within a function. The difference between the two are how they are invoked, and their ability to change the working environment. You will also create variables to count the number of rows, store the result in a variable and then do something as many time as there are rows. To perform a task using VBA you return an object that represents the appropriate Excel element and. As nouns the difference between method and procedure is that method is a process by which a task is completed; a way of doing something while procedure is a particular method for performing a task. To create a VBA procedure, you follow many of the same steps you follow when you created macros. -You can pass in variables as required We always wrote everything in functions and tried to stay clear of procedures. There are two types of VBS procedures: Sub procedures and Function procedures. Subs, functions. I cover Function procedures in this separate Excel tutorial. Create a new workbook. The following VBA performs the same action as the above example. dll) to pause code execution, because it is the most accurate and legible of the three methods. Function XLMod(a, b) ' This replicates the Excel MOD function XLMod = a - b * Int(a / b) End Function. ” There are two ways of assigning a shortcut key to a macro in excel vba. NET page which contains the ReportViewer 2012 control. Any sub or function that takes parameters REQUIRES the parens. Public Function Square(dbl As Double) As Double Function procedure. This kind of code item can also be called a function or a sub-routine. This means that the line that calls one Sub can pass values to another Sub. Constructors. Just type the word Call then space, then type the name of the macro to be called (run). Select Tools, then Macro, and then Visual Basic Editor to display the Visual Basic Editor. For example, proper SQL syntax, proper VBA syntax, and proper referencing of controls are three common points. 0 and Visual Basic. At the module level, there is no difference between Dim and Private. The technology was developed originally to interface with any data source, not just SQL. If you need more help, then please explain a bit more you objective. How can I jump to a particular procedure or function in the Visual Basic Editor? If this is your first visit, then welcome! Be sure to check out the FAQ by clicking the link above. Other languages do other things. The difference between Functions and Subs First, though, in case you are wondering what the difference is between a Function and a Sub, it's this: Functions return a value, and Subs don't. The CheckSolverIntl function below calls two additional functions which perform the loops. If you want Excel VBA to perform a task that returns a result, you can use a function. To create a VBA procedure, you follow many of the same steps you follow when you created macros. Sub Procedure sample. The set of functions that a VBA routine, or macro, can use to control its host application is the same set of functions that the Automation client can use to control the application externally, regardless of the programming language for the controller. Generally speaking, functions return a value, whereas procedures don't (so a procedure. query and stored procedure do the same thing but the difference is that a query should be compiled everytime the query is executed,while the stored procedure is in compiled form when executed first time. Flexcut Right-Handed Teddy Four Piece Scorp KN150 Roll 651646501507 The basic difference between a function and a subroutine is that the function returns value and the subroutine doesn’t. ∟ "Property Let/Set/Get" Procedures. These two types of procedures allow your program to perform actions. In Excel Visual Basic, a set of commands to perform a specific task is placed into a procedure, which can be a Function procedure or a Sub procedure (also known as functions and subroutines). The confusing part is when people use these terms, they're not always referring to the pure definitions. A Function, as its name suggests, is like a little program that calculates something, returning the value to the caller. Format (n, "style argument"). Reverse String Search Function in VBA: InStrRev. Here LCase function converts both the strings to lower case characters and the InStr statement results into 1. VBA Sub Procedures. If you're working with Excel's Visual Basic Editor, a procedure is the block of statements enclosed by a declaration statement and an End declaration. Here is an example:. Sub IF_Loop() We want to color all the cells in range B9:B18 green if their cell value is between 1 and 400. Function, Sub, Method, Property. Function Procedures A Function procedure is a series of VBScript statements enclosed by the Function and End Function statements. The call is made by entering the procedure name at the relevant point of the program. If you use the RunCode macro action to call a function, Access looks for the function with the name specified by the Function Name. Constructors. NET, Function and Subroutine are two types Procedure. The difference between when to use Sub and Function in VBA can be confusing. For all general questions relating to Excel but not including VBA or formulas. When programming VBA you write sequences of VBA statements in procedures in modules. You can also write programmer-defined procedures (Subs and Functions), which you would use not to respond to an e. You can also write programmer-defined procedures (Subs and Functions), which you would use not to respond to an e. datapigtechnologies. Query(Of SubCategory. This ensures all cleanup code (normally at the bottom) is executed and makes it easier for future developers (which may be you) to maintain. It is slight, can you spot it? MsgBox "Done" TheSentence = InputBox("Type Text Please", "Using the VBA Input Box") The difference is the equal sign before the function. Output Required. generally sub procedures are called by using command button or by another sub procedure. Net - Sub Procedures - As we mentioned in the previous chapter, Sub procedures are procedures that do not return any value. A sub can however, take an argument by reference and modify it, something some consider the same as the sub returning a value. I need to take three elements and create a sha1 signature from it to add as &authSignature=New Project->Visual Basic->WPF Application. What is the difference between a sub procedure and a function in Visual Basic 2013 ? In Visual Basic 2013, sub procedure is a procedure that performs a specific task and to return values, but it does not return a value associated with its name. In the Excel VBA example above, a simple Sub procedure has been written that deletes column C from the active worksheet when run. Dim FileName as String. Procedures can be passed parameters to execute different behavior based on those values. "We can use in a function/sub in the class module" I took this to mean that you could run class modules independently like normal modules, but of course I was mistaken. The Range property will accept one or two arguments, with the second one being optional. 100% Free Chilkat Upload Component for Visual Basic 6. Generally speaking, functions return a value, whereas procedures don't (so a procedure. cannot be called from anywhere in a project. Many Visual FoxPro developers have an aversion to anything that bears the name “Visual Basic”. I cannot for the life of me get this to work from Powershell. The two procedures do essentially the same thing, that is, divide a number by two. There two types of procedures used for VBScript: Sub. The generic name for both is a procedure. NET: those that return a value (Functions) and those that do not return a value (Sub Procedures). This is short for By. Outputting an Array via an output argument It is normally good coding practice for a procedure's arguments to be inputs and to output via the return value. However, it can return a value through a variable name. Calling Sub and Function procedures. Public Function GetOutlookVersoin() As String Return Me. A function procedure can take arguments (constants, variables or expressions that are passed to it by a calling procedure). Make your work-life easier. If you want to execute a series of statements without returning any value, then you can use sub procedures. First, they use Function procedures instead of Sub procedures. How can I jump to a particular procedure or function in the Visual Basic Editor? If this is your first visit, then welcome! Be sure to check out the FAQ by clicking the link above. To get time difference you need to use TimeSpan object, with code like this: TimeSpan ts = DateTime1 - DateTime2; For example, if you want to calculate time difference between server time and UTC time: [ C# ] protected void Page_Load(object sender, EventArgs e) {. Functions return a value, often based on a variable. but sub does not return any thing. Object, ByVal e As System. Sometimes however we want to end the execution of a function or procedure early, simply by leaving the current execution scope. NET, Function and Subroutine are two types Procedure. Creating a VBA Module. Syntax of SUBSTRING Function : SUBSTRING (expression ,start ,length) expression is a string from which part of a string is returned It can be character string, binary string, text, image, a column, or a column. On the other hand, a procedure is like a little routine that performs something, and then just finishes. Just type the word Call then space, then type the name of the macro to be called (run). Am I right?. If you're working with Excel's Visual Basic Editor, a procedure is the block of statements enclosed by a declaration statement and an End declaration. Reverse String Search Function in VBA: InStrRev. Substring () is a Function, because you want some sort of answer back, and an answer that you can then use elsewhere. Sub procedures are very useful for validating user input, reading files, printing output and general housekeeping. All the data are based on the parameters that we choose in the ASP. Call a Sub procedure by using the procedure name followed by the argument list. By using built-in functions you save time in coding and debugging work that has already been provided for you. A module-level variable remains in existence while Visual Basic is running until the module in which it is declared is edited. You can run a Sub procedure in the VBA Editor by pressing F5 or from the menu bar Run. We can run one procedure from another. If you don’t understand Function, Sub, Method, Property Differences, you will find my tips confusing and difficult to use. SELECT When Assigning Variables. A constructor is a special type of subroutine called at the creation of an object. As a VBA function, you can use this function in macro code that is entered through the Microsoft Visual Basic Editor. A Sub procedure returns no value. 3) IN OUT parameter: These types of parameters are used to send values and get values from stored procedures. Net Timer In VB 6. Of course if you know the stored procedure returns complete entities you can specify that in the function mapping dialogbox and if there is already a complext type that matches the stored procedure result you can select the complext type, but you do not need to create neither an entity nor a complex type before importing and mapping the stored. net Calculate a Bill (pp 5-2) Using Functions and Sub Procedures Introduction to Programming Using Visual Basic Visual Basic Programming Challenge 5-pp2: Calculating Restaurant Bill with Functions and Subs Write a program to compute customer's bill. Only functions and some extended stored procedures can be executed from within a function. Procedures do not return values. On the other hand a VBA Sub procedure can be executed directly and can also accept parameters. Subs can be executed by running it from Excel. A procedure only performs some actions, it is invoked because of its side effects. 3, “Date and Time Types” , for a description of the range of values each date and time type has and the valid formats in which values may be specified. Procedures, however, do not return values. Ideally, each Visual Basic procedure should handle one—and only one—task, to make this easy to remember. A Function And. net Calculate a Bill (pp 5-2) Using Functions and Sub Procedures Introduction to Programming Using Visual Basic Visual Basic Programming Challenge 5-pp2: Calculating Restaurant Bill with Functions and Subs Write a program to compute customer's bill. By default, Excel VBA passes arguments by reference. NET, Function and Subroutine are two types Procedure. VBA Example: Run Another Macro from a Macro. A procedure is a block of Visual Basic statements inside Sub, End Sub statements. Any sub or function that doesn't have parameters may optionally have or not have the parens. How to trap and log the errors reported while a Microsoft Access database is in use. Sub procedures CAN be called without a call keyword. This lesson assumes that you can navigate the Visual Basic IDE, and create a simple project with which to test code. In function we can return values as boolean, string and other data data types. As nouns the difference between method and procedure is that method is a process by which a task is completed; a way of doing something while procedure is a particular method for performing a task. Sub and function procedure. This notion of using subroutine is usually called function (or procedure) in most programming languages. Version End Function. The difference between the two are how they are invoked, and their ability to change the working environment. As a VBA function, you can use this function in macro code that is entered through the Microsoft Visual Basic Editor.