vinnu

vinnu

  • NA
  • 61
  • 202k

please correct the code (indian number format code)

Nov 4 2010 3:19 AM
hi....

The code is about place the comma's (,) i.e separator between numbers
in this format (12,21,21,123) it works good..

but when there's a decimal point such as 12345.58 it will show as 12,346.. 
it will round up the values.. ( which i dont want that .. i want as it value to be printed )
 
and one more problem  if there five digit with two decimal i.e(12345.00) it will show correct
i.e (12,345.00) but if i there four digit with two decimal i.e(1234.00 ) it will show this #error

[code]

Public Function FormatIndian(ByVal Amount As decimal) As String  
Dim strAmount As String
Dim strGrpsArr() As String
Dim lngPos As Long
Dim lngIndex As Long

   strAmount = Format$(Amount, "#")
   If Len(strAmount) < 4 Then
      FormatIndian = strAmount
   Else
      lngIndex = (Len(strAmount) - 2) \ 2
      ReDim strGrpsArr(lngIndex)
     
      strGrpsArr(lngIndex) = Mid$(strAmount, Len(strAmount) - 2)
     
      lngPos = Len(strAmount) - 4:  lngIndex = lngIndex - 1
      Do
         strGrpsArr(lngIndex) = Mid$(strAmount, lngPos, 2)
         lngPos = lngPos - 2:       lngIndex = lngIndex - 1
         If lngPos = 0 Then strGrpsArr(0) = Left$(strAmount, 1)
      Loop Until lngPos <= 0
     
      FormatIndian = Join(strGrpsArr, ",")
      Erase strGrpsArr
   End If
        Return  FormatIndian 
End Function

[/code]
please modify the code .. the code is in ssrs report properties->code tab..
help me...


Answers (1)