PowerBuilder Function Convert Decimal To String gf_convert_decimal_to_string
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | //Function Name : gf_convert_decimal_to_string //Argument Name : adec_value, Arg Type : decimal, Pass By : Value //Return Type : String //Example : adec_value = 5.5000 //Return : "5.5" Long ll_value_temp, ll_value_decimal, ll_pos String ls_value If adec_value = 0 Then Return "0" ll_value_temp = Truncate(adec_value, 0) ll_value_decimal = (adec_value - ll_value_temp) * 10000 ll_pos = 5 If Mid(String(ll_value_decimal), 4, 1) = "0" Then ll_pos = 4 If Mid(String(ll_value_decimal), 3, 1) = "0" Then ll_pos = 3 If Mid(String(ll_value_decimal), 2, 1) = "0" Then ll_pos = 2 If Mid(String(ll_value_decimal), 1, 1) = "0" Then ll_pos = 1 End If End If End If End If If ll_value_decimal = 0 Then ll_pos = 1 If ll_pos - 1 = 0 Then ls_value = String(ll_value_temp) Else ls_value = String(ll_value_temp) + "." + Left(String(ll_value_decimal), ll_pos - 1) End If Return ls_value |
Good Luck!