Jerry Dausman's profileThere's an answer to you...BlogLists Tools Help

Blog


    May 05

    ASP to Excel Zip Code Format

    So we had a problem today.  We were trying to create, from an .asp page, an Excel spreadsheet that users could download.  One of the columns carried zip codes, but the leading zeros of the zip codes were dropped, since Excel thought of these as numbers.  Well, there's a lot of complicated things you can do, such as <meta> tags and such, but what's the easiest way to get this data into Excel, and have it display correctly?  Just write the data in an HTML style table and use a style tag that Excel recognizes.
     
    The example below is a simple spreadsheet, saved with the .xls extension for Excel.  It has only two cells, both with the zip code value "02139" included.  Notice that the second cell has a class attribute of "txt" however.  That makes all the difference.
     
    <html>
    <head>
      <style>
      .txt {mso-number-format:\@;}
      </style>
    </head>
    <body>  <table>
        <tr>
          <td>02139</td>
          <td class='txt'>02139</td>
        </tr>
      </table></body>
    </html>
    August 24

    CapArea.NET

    Attended the monthly meeting of CapArea.NET user group last night, after a nice meal with their past president.  If you live in the DC area and haven't attended a meeting yet ... stop by.  I always learn something new, there are Microsoft Evangelists almost always present to ask questions of, and you might even win a door prize!  Last night the presentation was on building custom windows controls in Visual Studio 2005.  (Great presenation.)
    The meetings are every 4th Tuesday night at the ATT building in Tysons Corner, Virginia.
    The directions are on their home page: http://www.caparea.net/default.aspx.
    August 17

    Programming Sudoku

    My kids have caught the Sudoku craze.  For those of you who aren't up on it ... Sudoku is a number puzzle that started in Japan, caught on in England, and is now invading newspapers here in the USA.  The general idea is that you have a 3 by 3 grid that you have to place all the integers 1 through 9 in.  Simple.  But then you place 9 of these 3 by 3 grids in a square and a a couple of rules.  Not only do all the integers 1 thorugh 9 have to appear in every small 3 by 3 grid, but they also have to appear once in each 9-square row and in each 9-square column of the bigger grid.  The picture below shows a very simple Sudoku puzzle that I just threw together.
     
    So I'm driving home with two of my three teenagers and I suggest that a program could solve the puzzle if we could pattern the logic that my kids use.  (My kids are fast when it comes to solving these puzzles.)  They didn't like the idea ... it wouldn't be any fun then.  I think the fun is in finding a pattern for the solution and proving it by programming it.  Actually, someone has already done that.  You can see the Sudoku Solver on Guy Hoghton's site: http://www.suduko.org.uk/  When you run Guy's solver it looks as though it's using a brute force approach.  I think there may be a faster way you could program it to run.
     
    Jerry's Method Each empty square can only hold certain integers.  Those integers are the intersection of three sets: the set of integers not used in the local 3 by 3 square, the set of integers not in its 9-square row, and the set of integers not in its 9-square column.  First you determine the set of possible integers for each blank square.  Then, starting with the square with the least possible integers you would select an integer to try first, adjusting the 'possibles' sets in the local square, the row and the column.  You may have to iterate with this procedure, but I think it would be faster.  What do you think?
     
    August 05

    Questions Unanswered Till Now

    Some quick info for my MS2310 students this week ... How do you create a custom textbox (or any other control) with added functionality?  See Windows Control Forms Samples on the MSDN site for a short discussion.  As for a short discussion on the how and why of strong named assemblies go to How Do I...Create an assembly with a strong name? on www.GotDotNet.com.  Finally, since I couldn't remember the VB code for event handlers (too much C# programming work lately) I looked it up on GotDotNet.com.  Here's how we can add event handling programatically ...
     
    ....
    Dim button1 As New Button
    Dim button2 As New Button
    ....
    AddHandler button1.Click, AddressOf button_Click
    AddHandler button2.Click, AddressOf button_Click
    ....

    'The event handling method
    Private Sub button_Click(sender As Object, evArgs As EventArgs)
        If (sender = button1) Then
            MessageBox.Show("Button1 Pushed!")
        Else If (sender = button2) Then
            MessageBox.Show("Button2 Pushed!")
        End If
    End Sub

     
    If you want to unlink the procedure from the event, just use the 'RemoveHandler' method.
     
    That's all for now ... I'm off on vacation!!!
     
    August 02

    Ask (correctly) and it Shall Be Given

    Thanks to Karla Carter for pointing us to "How to Ask a Question (support.Microsoft.com/kb/555375)".  This will be useful in those classes where I have students who ... let us say ... don't have all the mental prerequisites! 
    August 01

    Seek and Ye Shall Find

    One of the sites I like to keep up with is my cousin Jack's.  He's a Lotus Notes geek (you know, that stuff from IBM, the original Evil Empire).  His last post is about www.Koder.com, the Google of internet available code routines.  Next time you can't find that esoteric function you read about ... give them a try.  They include links to code for all kinds of languages and operating systems.  Really neat.