Terje Isaksen Developer blog

2011-06-23 (Thursday)

600+ different programming languages

Filed under: Developing — Terje Isaksen @ 12:58
Tags:

http://99-bottles-of-beer.net/

Every language from A+ to ZZT

One C# version is:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _99Bottlez
{
    class Program
    {
        static void Main(string[] args)
        {
            int countOfBottles = 10;
            string lineTemplate = @"{X} bottles of beer on the wall, {X} bottles 
                                  of beer. Take one down and pass it around, {Y} 
                                  bottles of beer on the wall.";

            string lastLine =  @"No more bottles of beer on the wall, no more   
                               bottles of beer.Go to the store and buy some 
                               more, {X} bottles of beer on the wall.";

            List<string> songLines = new List<string> ();
            Enumerable.Range(1, countOfBottles)
                .Reverse()
                .ToList()
                .ForEach
                 (c => songLines.Add(lineTemplate.Replace("{X}", 
                 c.ToString()).Replace("{Y}", (c-1)!=0?(c - 1).ToString():@" No 
                 more bottles of beer on the wall.")));

            //Add the last line
            songLines.Add(lastLine.Replace("{X}", countOfBottles.ToString()));

            songLines.ForEach(c => Console.WriteLine(c));
            Console.ReadLine();
        }
    }
}

2011-06-21 (Tuesday)

Excel tips and tricks

Filed under: Developing — Terje Isaksen @ 14:40
Tags:

New function in Excel 2007:

=IFERROR(expression; safevalue)

If something is wrong, giving #ERROR och #VALUE – the safevalue is used. Combination of IF() and ISERROR()

To prevent user from saving workbook:

Private Sub Workbook_BeforeSave (ByVal SaveAsUI As Boolean, Cancel As Boolean) 
    '  Following line will prevent all saving
    Cancel = True
    '  Following line will prevent the Save As Dialog box from showing
    If SaveAsUI then SaveAsUI = False
End Sub

Source: http://www.ozgrid.com/forum/showthread.php?t=26224&p=133079#post133079

To be able to save this anyway, go to Developer tab and click on Design Mode – then macros will not run, and you are able to save.

Create a free website or blog at WordPress.com.