Thursday, January 29, 2009

XEN Bio Error

XEN error

Friday, January 23, 2009

Repeating Habits

I had a student's code not working. He was getting this error: A first chance exception of type 'System.FormatException' occurred in mscorlib.dll. Goggleing the error was no help. My first reaction was to take my working code and compare it to his broken code. See the examples below. Can you see the difference? I did not. The bad habit I had was taking my working code and comparing it line by line after the lines by line. I have fixed many student errors this way. It did not work this time. I also let the student see the code also. I was unable to see the error but the student found the error later.


Working Code:


btnDisplayCost_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplayCost.Click




Dim strEnterNumberOfTickets As String


Dim intEnterNumberOfTickets As Integer


Dim decTotalCostOfTickets As Decimal



strEnterNumberOfTickets = Me.txtEnterNumberOfTickets.Text

intEnterNumberOfTickets = Convert.ToInt32(strEnterNumberOfTickets)

decTotalCostOfTickets = intEnterNumberOfTickets * cdecTotalCostOfTickets

Me.lblTotalCostOfTickets.Text = decTotalCostOfTickets.ToString("C")




Bad Code:

frmConcertTickets_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


Dim strEnterNumberOfTickets As String

Dim intEnterNumberOfTickets As Integer

Dim decTotalCostOfTickets As Decimal


strEnterNumberOfTickets = Me.txtEnterNumberOfTickets.Text

intEnterNumberOfTickets = Convert.ToInt32(strEnterNumberOfTickets)

decTotalCostOfTickets = intEnterNumberOfTickets * cdecTotalCostOfTickets

Me.lblTotalCostOfTickets.Text = decTotalCostOfTickets.ToString("C")



Friday, January 16, 2009

Closing Outlook before Backup

I backup my Outlook file to AVG online backup (this is free). I need Outlook to close automatically so the backup will be successful. I found a utility that makes it work. This command line utility adds a lot of function to scripts for XP: you can clear the recycle bin and clipboard. You can also close applications so the command is:

nircmd.exe killprocess outlook.exe

You can learn more about this utility by going here.

Make sure you copy all the files to your c:\windows\system32 folder or where ever you have you operating system installed.

Finally, I created a task and scheduled it to run right before my backup.