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.


 

Tuesday, December 9, 2008

Excel Formula not Working

Symptoms:

I was working in Excel spreadsheet that was a downloaded csv sheet. I would put in a formula to sum a column and I would get this:

A

40

60

20

=sum(a1:a3)


The formula would not work. I changed it to average and still you only would get the text. The number

Gathering Information

I looked at the sheet and found that all the cell where formatted as text. This was because the sheet was an imported comma separated download of grades. Number are generally set flush right but the text was flush left.

Hypothesis

H1 Convert the cell format to numbers general. (Failed)

H2 Use error correct to covert text to numbers. (Accepted)

Results

The number stored as texts can be corrected using the excel error correcting utility. The cells have a green triangle in the upper left corner. See the video in previous post. You click on the diamond shaped and you get a dropped menu. Select convert to number.

See the movie in the previous steps to see the hands on instruction.

Reflection

Exporting data is tricky. This is a very simple example but imagine a whole school system's data needing adjustments.





Excel: Numbers as Text Video

Monday, December 8, 2008

Wednesday, December 3, 2008

Jetflash won’t Take Large File

My Jetflash 64 gb flash drive is stating: The disk in the destination drive is full. Insert a new disk to continue.

The disk is only half full and the file I am trying to copy is only 10 gigs.

Gathering Information

I have found out that the issue is the file format for the flash drive. The flash drive is formatted fat32 and that has a limit of 4 gigs for file sizes. See this link.


 

The error message indicates the disk is full not that file is too large.

Hypothesis


 

H0. Formatting the drive to be NTFS will fix the issue.


 

Results


 

H0 worked. I could not format the drive to NTFS on an XP PC but I could on Server 2008 PC.

Reflection

I found myself deleting all files and restarting the usb drive to try to fix this issue.  I assumed that the Windows has just lost track of the size of the disk. I wasted about 20 minutes on this before I did some research. Live search did not return the correct information but Google did. I need to not waste time before doing research.

I found the information on tansendusa.com very hard to find.  I don't think this website has been validated.  The webmaster seems to a lot of bells and whistles but it is really slow.

Tuesday, December 2, 2008