'------------------------------------------------------------------------------- ' There is no format option, set let build our own ' expN1 Maximum length of the value ' expN2 Value ' expN3 Number of decimal places '------------------------------------------------------------------------------- Private Function FormatNumber(tnLength, tnValue, tnDecimal) Dim lcValue As String Dim lnPosition As Integer Dim lcFormat As String ' Converts the numeric value into a character lcValue = CStr(tnValue) ' Try to find the decimal location lnPosition = InStr(lcValue, ".") ' If there is no decimal, the formula would be a little different than if we have a decimal If lnPosition = 0 Then lcFormat = Space(tnLength - Len(lcValue) - tnDecimal) + Format(tnValue, "#0") Else lcFormat = Space(tnLength - lnPosition - tnDecimal) + Format(tnValue, "#0." + PadR("", tnDecimal, "0")) End If ' Returns the value FormatNumber = lcFormat End Function '------------------------------------------------------------------------------- ' There is no Pad right function so let build our own ' expC1 String ' expN1 Length of the string ' expC2 Pad character '------------------------------------------------------------------------------- Private Function PadR(tcString, tnLength, tcCharacter) Dim lnCounter Dim lcString lcString = "" For lnCounter = 1 To tnLength - Len(tcString) lcString = lcString + tcCharacter Next PadR = lcString + tcString End Function