Tokyo PC Users Group
	  Home Page
Home
Members Only
Newsletter
Newsgroups
Become a Member
Meeting Info & Map
Officers
Members
Corporate Members
Photos
Workshops & Training
Other Clubs
Job Hunting?
Constitution


How to get started in Programming

by Robert Altena

The question gets asked every now and then when I do development work for one of my clients. I love it when they ask the question: It means my clients are able to see the value of the work done for them. It means my clients are interested in what is being done for them. And it means they are seeing me enjoying working for them. All of this is great, and this is the right reason to start programming: Programming computers is fun.

The answer to the how to get started question is not that easy though. "Programming" used to be very straightforward and a little boring. Those days are long gone. Computers are used for more than calculations these days. In fact it is safe to say that most people use their PC for anything but calculations. The PC is used to communicate, produce documents, collect information, monitor information. The PC is used for a very large number of tasks.

With the large number of problems we solve using our PC comes a vast array of programming languages and tools to do these tasks. Although you can do almost anything with a basic text editor such as Notepad or VI (this will make me some friends), you really would like to use something a little more advanced. In this article I will try to give you one suggestion to get started. It is not the only way to get started on your programming skills.

First a disclaimer: My specialty is to build applications on the Windows platform. This article is aimed at people with a Windows machine who have one of the Microsoft Office applications installed. I am using Word 2000 and Excel 2000. If you use a different version, some of the menus may be located in a different place and the keyboard shortcuts may have been re-assigned.

You already have a development tool
on your PC!


If you are using any of the Microsoft Office applications, then you should have access to a decent development environment: the VBA editor that comes with each office application. Each article on programming should start with a "Hello World" application. In this article we will have two of those, just to be different. First, bring up your VBA editor. Start up Microsoft Excel or Microsoft Word. Then press the ALT and F11 keys. If you fail to press the keys, try Tools > Macro > Visual Basic Editor from the menu.

That will bring up your editor. Now all we need is a place to write our code, so we will add a module. You can choose (In the Visual Basic Editor) Insert > Module. Now you are all ready to have the PC do exactly what you want it to do! It may try to fight back, but you have won half the battle just by getting here. Now before we start playing around with real code: close all important documents that you may have open. We are not doing anything fancy, but it is a good idea to really make sure you are unable to do any damage to your own documents. When I write Excel or Word macros I never ever have any documents open other than the ones needed for the current project.

Start Coding

We are in business and ready to code. If you are using MS-Word, type the following:

Sub HelloWorld()
      Documents.Add
      Selection.TypeText "Hello World!"
End Sub


You can run your own code in a number of ways: In the Visual Basic Editor, place the cursor on your code and press the F5 key. From your MS Word window choose Tools Macro Macros. Select HelloWorld from the list and press the Run button. Pretty cool for a first shot at writing code, isn't it?
Here is the code for Excel:

Sub HelloWorld()
      Workbooks.Add
      Range("B2").Value = "Hello World!"
End Sub


You should be a little surprised as to how little code you needed to get where you are now. In fact, we could have done with even less code: The first line in each sample could have been omitted. ("Documents.Add" for the word sample and "Workbooks.Add" for the excel sample.) Go ahead, try it and see what happens.

What is Next?

Congratulations: You now have started programming. In the next articles in this series we will look at the Visual Basic Editor in more detail. We will do samples that are a lot more exciting than this article. If you want me to visit a particular topic in this series: please send me e-mail at Robert@RobertAltena.com. Try to keep your requests as general as possible though: we want this series to be useful to as many people as possible.



© Algorithmica Japonica Copyright Notice: Copyright of material rests with the individual author. Articles may be reprinted by other user groups if the author and original publication are credited. Any other reproduction or use of material herein is prohibited without prior written permission from TPC. The mention of names of products without indication of Trademark or Registered Trademark status in no way implies that these products are not so protected by law.

Algorithmica Japonica

September , 2002

The Newsletter of the Tokyo PC Users Group

Submissions : Editor


Tokyo PC Users Group, Post Office Box 103, Shibuya-Ku, Tokyo 150-8691, JAPAN