bryandurant
04-08-2014, 08:15 AM
I have this code and when i run the code with a specific area code of " Durango, CO, 81301" i get an error message "Value was either too large or too small for a Decimal". Here is the part of the code that is coming up with the debug portion of the code.
For Each row As System.Data.DataRow In Globals.dt_Geocodes.Rows
'If Convert.ToDecimal(row.Item(1)) > (Convert.ToDecimal(alLongLat.Item(0)) - 1) _
'AndAlso Convert.ToDecimal(row.Item(1)) < (Convert.ToDecimal(alLongLat.Item(0)) + 1) _
'AndAlso Convert.ToDecimal(row.Item(2)) > (Convert.ToDecimal(alLongLat.Item(1)) - 1) _
'AndAlso Convert.ToDecimal(row.Item(2)) < (Convert.ToDecimal(alLongLat.Item(1)) + 1) Then
If row.Item(3).ToString <> String.Empty Then
Dim iDistance As String = String.Empty
Dim alCols As New System.Collections.ArrayList
iDistance =
Convert.ToDecimal((Math.Acos(Math.Sin(Convert.ToDecimal(alLongLat.Item(0)) * 3.1415926535897931 / 180) _
*
Math.Sin(Convert.ToDecimal(row.Item(1)) * 3.1415926535897931 / 180) _
+
Math.Cos(Convert.ToDecimal(alLongLat.Item(0)) * 3.1415926535897931 / 180) _
*
Math.Cos(Convert.ToDecimal(row.Item(1)) * 3.1415926535897931 / 180) _
*
Math.Cos((Convert.ToDecimal(alLongLat.Item(1)) - Convert.ToDecimal(row.Item(2))) _
* 3.1415926535897931 / 180)) * 180 / 3.1415926535897931) * 60 * 1.1515).ToString(
"f2")
Dim nRow As System.Data.DataRow = dt.NewRow
nRow.Item(0) =
Convert.ToDecimal(iDistance)
nRow.Item(1) = row.Item(4).ToString
nRow.Item(2) = row.Item(5).ToString
nRow.Item(3) = row.Item(6).ToString
nRow.Item(4) = row.Item(7).ToString
nRow.Item(5) = row.Item(8).ToString
nRow.Item(6) = row.Item(9).ToString
nRow.Item(7) = row.Item(10).ToString
dt.Rows.Add(nRow)
End If
Any help would be greatly appreciated!
Bryan
For Each row As System.Data.DataRow In Globals.dt_Geocodes.Rows
'If Convert.ToDecimal(row.Item(1)) > (Convert.ToDecimal(alLongLat.Item(0)) - 1) _
'AndAlso Convert.ToDecimal(row.Item(1)) < (Convert.ToDecimal(alLongLat.Item(0)) + 1) _
'AndAlso Convert.ToDecimal(row.Item(2)) > (Convert.ToDecimal(alLongLat.Item(1)) - 1) _
'AndAlso Convert.ToDecimal(row.Item(2)) < (Convert.ToDecimal(alLongLat.Item(1)) + 1) Then
If row.Item(3).ToString <> String.Empty Then
Dim iDistance As String = String.Empty
Dim alCols As New System.Collections.ArrayList
iDistance =
Convert.ToDecimal((Math.Acos(Math.Sin(Convert.ToDecimal(alLongLat.Item(0)) * 3.1415926535897931 / 180) _
*
Math.Sin(Convert.ToDecimal(row.Item(1)) * 3.1415926535897931 / 180) _
+
Math.Cos(Convert.ToDecimal(alLongLat.Item(0)) * 3.1415926535897931 / 180) _
*
Math.Cos(Convert.ToDecimal(row.Item(1)) * 3.1415926535897931 / 180) _
*
Math.Cos((Convert.ToDecimal(alLongLat.Item(1)) - Convert.ToDecimal(row.Item(2))) _
* 3.1415926535897931 / 180)) * 180 / 3.1415926535897931) * 60 * 1.1515).ToString(
"f2")
Dim nRow As System.Data.DataRow = dt.NewRow
nRow.Item(0) =
Convert.ToDecimal(iDistance)
nRow.Item(1) = row.Item(4).ToString
nRow.Item(2) = row.Item(5).ToString
nRow.Item(3) = row.Item(6).ToString
nRow.Item(4) = row.Item(7).ToString
nRow.Item(5) = row.Item(8).ToString
nRow.Item(6) = row.Item(9).ToString
nRow.Item(7) = row.Item(10).ToString
dt.Rows.Add(nRow)
End If
Any help would be greatly appreciated!
Bryan