I downloaded Directory Domination v1.01 tool few months ago. It’s free but pretty outdated now. As you probably noticed there are 200 directories listed in Directory Domination v1.01. (more…)
My favorite great online radiostations are Groovetech and NPR. Both satisfy my needs as an end user and are great examples of streaming sites that go the distance to make a lot of unique content available in an easy to navigate, high quality format.
Using Recursive Prime Factorization and Prime Indexes to Represent Integers in Terms of Grouping Operators
The idea of this program is to represent any integer purely in terms of grouping operators “(” and “)”. These 2 symbols will give a binary representation of the integers. Since the grouping operators will be balanced, we are guaranteed that the density of (‘s and )’s will be equal. Also, since the ) that matches the first ( indicates the end of a number, arbitrary length integers can be strung together without any special “record separator” indicator.
We’re going to create a very simple macro that will help introduce the language to you. Follow these steps:
- Create a new blank workbook in Excel.
- Turn on the Macro Recorder (Tools, Macros, Record New Macro). Make sure that you record the macro in ThisWorkbook. Name the macro ValueInCell.
- Using the mouse select cell F5. In this cell type the word “Hello” and press Enter.
- Stop the macro recorder.
Now take a look at the VBA code behind this macro. Open the Visual Basic Editor, make sure the project explorer is visible (Ctrl-R will show it), locate your project, expand the Modules folder and double-click Module1.
From the first tutorial you should recognise the structure of what you can see. The first 4 lines of the procedure are comments (which you will recognise as starting with an apostrophe and being green). The first line of actual code is this:
This instruction tells VBA to select the cell F5. The next line is slightly more cryptic.
ActiveCell.FormulaR1C1 = “Hello”
ActiveCell refers to exactly that – the active cell i.e. the one that is currently selected. FormulaR1C1 can be used to assign a formula or a value to a cell. For example, this code would also work:
ActiveCell.FormulaR1C1 = “=SUM(R1C10:R10C10)”
If you’re not familiar with the R1C1 style of referencing cells then this may seem confusing (suffice to say that it will put the formula SUM($J$1:$J$10) into the active cell). You can also specify a constant e.g. “Hello” as we have done in our macro.
The final line of is similar to the first:
Can you guess what it does? That’s right, it selects cell F6!
The usual syntax of VBA is to write the name of the object that we’re working with e.g. Range(“A1″) followed by a full-stop/period and then the name of the attribute we want to change or the command we want to carry out. If we’re changing the value of an attribute then we use an = sign followed by the new value e.g.
ActiveCell.FormulaR1C1 = “Hello”
If we want to carry out a command then we specify the object we’re working with followed by the name of the command that we want to carry out e.g.
OK, you can close the workbook now. Don’t bother saving it, unless you really want to.
At this point I’m going to introduce the concept of an object orientated programming. Although that term may sound confusing it is actually a very simple concept…
Imagine a car – it could be your own trusty Holden Barina/Vauxhall Corsa or it could be something less exotic, such as a Porsche 911 or a Maserati Spyder. A car has certain attributes, such as number of seats, colour, number of gears, engine size, whether it has a turbo or not and so on. It can also do things such as start, go forwards, go backwards and stop.
Now I want you to think about your computer. Like your car it also has attributes, such as memory size, hard disk size, processor speed and colour. It can also do things such as boot up, run a program, close a program and shut down.
A car and a computer are objects – you can see and feel them and you can experience these objects “doing things”. The premise of object orientated programming (or OOP for short) is that the programming environment consists of objects – they may not have a physical existence (except for within your computer) but they are treated as though they do. In Excel there are many different objects (hundreds). Some of the more common ones are Range, Worksheet and Workbook.
- Objects have attributes. In object orientated programming (again, OOP for short) attributes are known as properties.
- Objects can do things. In OOP the command to make an object do something is called a method.
- Objects can react to something. In OOP reactions are known as events.
As mentioned above, you change or set the value of a property by specifying the object followed by a full-stop, then the name of the property, an equals sign (=) and then the value you want to assign i.e.
Object.Property = NewValue
Note! In general, when assigning a text value to a property, you enclose the text in speech marks e.g.
ActiveCell.Value = “Hello. This cell contains text!”
However, when assigning a numeric value to a property you do not generally need to use speech marks:
ActiveCell.Value = 100
Anyway, when you want to carry out an object’s method you type the object name followed by a full-stop and then the method name e.g.