PCWorld Programming Column
Feb 2010 Article:

The Code for February 2010 is available here as a zip file

Don't forget to change the connection string Data Source to your SQL Server name


Dec/Jan Article:

The Code for Dec/Jan is available here as a zip file

Don't forget to change the connection string Data Source to your SQL Server name


November Article:

The Code for November is available here as a zip file

Don't forget to change the connection string Data Source to your SQL Server name


October Article:

The Code for October is available here as a zip file

Don't forget to change the connection string Data Source to your SQL Server name


Article 3:

The Code for Article 3 is available here as a zip file




Article 2:

I will post the UselessCalculator code shortly. In the meantime feel free to contact me using the contact page. Answers to article one are below in the article one section.

Article 1:

Please note: Due to space issues in the print magazine, the example code was compressed and tabs were omitted. It’s is a good idea to tab indent blocks of code.

For example


public void MyMethod(int someNumber)
{
    string s = “Hi there”;
    for (int i = 0; i <= someNumber; i++)
    {
        Console.Write(i);
    }
}

Article 1 Code:

Some people have been having trouble with the code in the magazine. Basically due to the space limitations on the printed page the code had to be formatted differently to a code file, or webpage. Just cut and paste below into an empty file and save it as article1.html and follow the directions as per the magazine.

<HTML>
<script type="text/javascript">
function PrintNumbers(startNumber)
{
    document.write("Count 20 numbers starting at " + startNumber);
document.write("<BR/>");
    for (i = startNumber; i < startNumber + 20; i++)
    {
        document.write(i);
        document.write("<br/>");
    }
    document.write("And we're done");
}
</script>
<body onload="PrintNumbers(1)">
</body>
</HTML>


Answers to article one:

Question 1:

Below is the code to complete question one from article one. There are only two changes. The function gets another parameter called loops,

function PrintNumbers(startNumber, loops)


which we then use in the for loop as the maximum amount of times to loop and add that to startNumber.

    for (i = startNumber; i <= startNumber + loops; i++)


And, of course we change the calling of PrintNumbers in the page load to include the amount of times to loop.

<body onload="PrintNumbers(1, 20)">

Full Code Below:

<HTML>
<script type="text/javascript">
function PrintNumbers(startNumber, loops)
{
    document.write("Count 20 numbers starting at " + startNumber);
document.write("<BR/>");
    for (i = startNumber; i <= startNumber + loops; i++)
    {
        document.write(i);
        document.write("<br/>");
    }
    document.write("And we're done");
}
</script>
<body onload="PrintNumbers(1, 20)">
</body>
</HTML>


Question 2:

The answer to question two is the same as above, but we simply change the values we pass into PrintNumbers for example if we want to start at 5 and print 50 numbers, we would
change the calling code for PrintNumbers to:


<body onload="PrintNumbers(5, 50)">



Feel free to contact me via the
contact page