Loading

Code fix for Lewis

  1. ' See if there is a decimal point in the results
  2.                     If InStr(RS.Fields.Item("field_area").Value, ".") > 0 Then
  3.                         ' Trim the fieldArea to two decimal places
  4.                         arrFieldSplit = Split(RS.Fields.Item("field_area").Value,".")
  5.                         ' ENSURE there are two decimal places in the JSON output to the user
  6.                         If LEN(arrFieldSplit(1)) = 0 Then
  7.                            strFieldArea = arrFieldSplit(0) & ".00"
  8.                         ElseIf LEN(Left(arrFieldSplit(1),2)) = 1 Then
  9.                             strFieldArea = arrFieldSplit(0) & "." & Left(arrFieldSplit(1),1) & "0"
  10.                         Else
  11.                             strFieldArea = arrFieldSplit(0) & "." & Left(arrFieldSplit(1),2)
  12.                         End If
  13.                     Else
  14.                         ' No decimal point found, lets add one
  15.                         strFieldArea = RS.Fields.Item("field_area").Value & ".00"
  16.                     End If

Comments

The original code was trying to split on decimal point, without first checking to see if it even existed.

Rich • 07 Mar 2014, 10:08:48 UTC