Archive for July, 2007

Dynamic Dialogs in Excel VBA

Thursday, July 19th, 2007

The problem:
You want to have a User Form (a VBA-Dialog) which

  • controls (buttons, text fields etc.) are created at runtime based on information that is read from e.g. a table
  • event handling of those controls is created at runtime.
  • For a solution of these problems check the following file and/or read on.
    Example Code for Dynamic Dialogs in Excel VBA

    Consider the following example: There is a table which contains products of some type. Each product has some properties like description, prize etc. This table is created by some database queries. Hence, you do not know how much entries the table will have.
    You want to provide the user of your Excel application with an easy way to select those products and insert them in another table (e.g. an invoice). If a user wants to insert a product into the invoice, he clicks a button and you would like to present him a User Form that has one button for each product. If he clicks on one button, the concerning product is inserted into the invoice table with its description, price etc.

    Dynamic Dialogs in Excel at Work

    (more…)

    Making function declarations talk: auto_ptr and memory management in C++

    Thursday, July 5th, 2007

    Here’s just something I wrote some time ago and rotted on my harddisk. It might be helpful for people new to C++.

    ———————-
    In all but the smallest projects, code is much more often read than (re)written. This means, that a large amount of the development time goes into reading code, which therefore should be made as easy as possible. It also means, that almost everything you can do, to make your code easier to be read should be done because the additional time you spent in writing the code will more than pay off in the future. We all know (and perhaps hate) some ways, to make code easier to read: use comments, use long variable names, give functions a clear name that corresponds to their purpose etc.

    These rules can be applied in almost every programming language. But if you and your fellow developers really know the programming language, you can do more. You can express certain expectations and warranties by using features of the language and by this, express yourself more clearly (special bonus: you may even omit a few comments, because your code speaks for itself). Additionally, sometimes the compiler and the runtime environment help you to enforce certain requirements on how your code is to be used (see Design by Contract).

    (more…)