tags:

views:

34

answers:

2

Here is the exception:

"Input string was not in a correct format."

Here is the line of code:

.Add(Integer.Parse(LoanData.Item("IsApplicantRaceAmericanIndian")).ToString)
+3  A: 

The text you're trying to parse must not represent a valid integer. For example it might be "ABC" or it might be blank.

Use Integer.TryParse instead of Integer.Parse for a more resilient parsing strategy:

Dim text As String = LoanData.Item("IsApplicantRaceAmericanIndian")).ToString()

Dim value As Integer
If Integer.TryParse(text, value)
    .Add(value)
Else
    ' The text could not be parsed. '
    ' Notify the user, log it, do whatever you like. '
End If
Dan Tao
A: 

As a tip, Integer.Parse won't handle empty or null strings. Try using Integer.TryParse if you are using .NET 2.0 or newer.

Diego Pereyra