The above example illustrates how sub procedures perform actions but do not return values. The following code shows an example of a simple VBA Sub procedure that will calculate the area. The sub-procedure does not return a value and can be called without a call keyword. Sub procedures are similar to functions with some minor differences. The below-given code calls the function that was defined above: The following code shows an example of a simple VBA function procedure that receives two arguments. To create the function in the VBA window, go to Insert > Module and it will create a new module. ![]() You can use the code over and over again in your program. If the statement is false, the loop is exited, and it jumps to the next statement.įunctions are the reusable code that can be called anywhere in the program. In a while loop, if the statements are true, they are executed till they encounter the Wend keyword. The following code will prompt the message box showing the value from 0 to 6 with the gap of 2. If it says the condition to be False, it executes the statements under the Else Part.įor loop is a control flow statement that allows the user to write a loop that can be executed repeatedly. If the condition is true, the lines under the body of the If statement are executed. The ‘If statement’ is a conditional statement that consists of an expression followed by another expression. If the condition is true, the lines of code under the If statement are executed.Įnter the marks in cell A1 and click on the command button to get the result. If, If-Else, For and While Loop If statement ![]() The left keyword will extract the characters from the leftmost side of the string. This is also known as concatenation.Ĭlick on the command button to get the following result. You can join the two strings by using & operator. String manipulation refers to the process of analyzing, manipulating, and effectively handling string values. When you click on the command button, you will get the following output:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |