Reputation: 4210
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)
Upvotes: 0
Views: 815
Reputation: 417
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.
Upvotes: 0
Reputation: 128377
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
Upvotes: 4