Mar 16, 2012 - 11 Using Arrays to Manage Numeric and String Data..... 12 Working with. Sample Projects on Disk. The Anatomy of a Visual Basic Program Statement. One Step Further: Inserting Code Snippets. Note The Visual Studio 2010 software is not included with this book. How to Print Invoice using C#? This article, along with any associated source code and files. How to Print Invoice using VB6?

Everybody in this country should learn how to program a computer. Because it teaches you how to think.' -Steve Jobs I wish to extend the wise words of Steve Jobs and say everyone in the world should learn how to program a computer. You may not necessary end up working as a programming or writing programs at all but it will teach you how to think. In this tutorial, we are going to cover the following topics. • • • • • What is VBA?

VBA stands for Visual Basic for Applications. Before we go into further details, let's look at what computer programming is in a layman's language. Assume you have a maid. If you want the maid to clean the house and do the laundry. You tell her what to do using let's say English and she does the work for you. As you work with a computer, you will want to perform certain tasks.

Just like you told the maid to do the house chores, you can also tell the computer to do the tasks for you. The process of telling the computer what you want it to do for you is what is known as computer programming. Just as you used English to tell the maid what to do, you can also use English like statements to tell the computer what to do. The English like statements fall in the category of high level languages.

Gotovie kursovie raboti po shehovcovu. VBA is a high level language that you can use to bend excel to your all powerful will. VBA is actually a sub set of Visual Basic 6.0 BASIC stands for Beginners All-Purpose Symbolic Instruction Code.

• It uses English like statements to write instructions • Creating the user interface is like using a paint program. You just have to drag, drop and align the graphical user interface controls. • Short learning curve. From day one that you start learning, you can immediately start writing simple programs. • Enhances the functionality of excel by allowing you to make excel behave the way you want it to Personal & business applications of VBA in excel For personal use, you can use it for simple macros that will automate most of your routine tasks. Read the article on Macros for more information on how you can achieve this. For business use, you can create complete powerful programs powered by excel and VBA.

The advantage of this approach is you can leverage the powerful features of excel in your own custom programs. Visual Basic for Applications VBA basics Before we can write any code, we need to know the basics first. The following basics will help you get started. • Variable – in high school we learnt about algebra.

Find (x + 2y) where x = 1 and y = 3. In this expression, x and y are variables. They can be assigned any numbers i.e.

1 and 3 respective as in this example. They can also be changed to say 4 and 2 respectively. Variables in short are memory locations. As you work with VBA, you will be required to declare variables too just like in algebra classes •. Rules for creating variables • Don't use reserved words – if you work as a student, you cannot use the title lecturer or principal. These titles are reserved for the lecturers and the school authority. Reserved words are those words that have special meaning in Vba and as such, you cannot use them as variable names.

• Variable names cannot contain spaces – you cannot define a variable named first number. You can use firstNumber or first_number. • Use descriptive names – it's very tempting to name a variable after yourself but avoid this. Use descriptive names i.e. Quantity, price, subtotal etc.

This will make your VBA code easy to read •. Logical operators - The concept of logical operators covered in the earlier tutorials also apply when working with VBA. These include • If statements • OR • NOT • AND • TRUE • FALSE Enable Developer Option • Create a new workbook • Click on the ribbon start button • Select options • Click on customize ribbon • Select the developer checkbox as shown in the image below • Click OK You will now be able to see the DEVELOPER tab in the ribbon VBA Hello world Now we will demonstrate how to program in VBA. All program in VBA has to start with 'Sub' and end with 'End sub'.