求两个C#.NET函数转换成VB.NET语句。 25
01.functionoutputmoney(number){02.if(isNaN(number)||number=="")return"";03.number=Mat...
01.function outputmoney(number) {
02. if (isNaN(number) || number == "") return "";
03. number = Math.round(number * 100) / 100;
04. if (number < 0)
05. return '-' + outputdollars(Math.floor(Math.abs(number) - 0) + '') + outputcents(Math.abs(number) - 0);
06. else
07. return outputdollars(Math.floor(number - 0) + '') + outputcents(number - 0);
08.}
09.//格式化金额
10.function outputdollars(number) {
11. if (number.length <= 3)
12. return (number == '' ? '0' : number);
13. else {
14. var mod = number.length % 3;
15. var output = (mod == 0 ? '' : (number.substring(0, mod)));
16. for (i = 0; i < Math.floor(number.length / 3); i++) {
17. if ((mod == 0) && (i == 0))
18. output += number.substring(mod + 3 * i, mod + 3 * i + 3);
19. else
20. output += ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);
21. }
22. return (output);
23. }
24.}
25.
26.
27.function outputcents(amount) {
28. amount = Math.round(((amount) - Math.floor(amount)) * 100);
29. return (amount < 10 ? '.0' + amount : '.' + amount);
30.} 展开
02. if (isNaN(number) || number == "") return "";
03. number = Math.round(number * 100) / 100;
04. if (number < 0)
05. return '-' + outputdollars(Math.floor(Math.abs(number) - 0) + '') + outputcents(Math.abs(number) - 0);
06. else
07. return outputdollars(Math.floor(number - 0) + '') + outputcents(number - 0);
08.}
09.//格式化金额
10.function outputdollars(number) {
11. if (number.length <= 3)
12. return (number == '' ? '0' : number);
13. else {
14. var mod = number.length % 3;
15. var output = (mod == 0 ? '' : (number.substring(0, mod)));
16. for (i = 0; i < Math.floor(number.length / 3); i++) {
17. if ((mod == 0) && (i == 0))
18. output += number.substring(mod + 3 * i, mod + 3 * i + 3);
19. else
20. output += ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);
21. }
22. return (output);
23. }
24.}
25.
26.
27.function outputcents(amount) {
28. amount = Math.round(((amount) - Math.floor(amount)) * 100);
29. return (amount < 10 ? '.0' + amount : '.' + amount);
30.} 展开
展开全部
专业一点啊,这明明是 Java 代码,怎么说是 C# 呢?
Imports System
'返回值类型自己改
function outputmoney(number as Double) as 类型
If True Then
If isNaN(number) OrElse number = "" Then
Return ""
End If
number = Math.Round(number * 100) / 100
If number < 0 Then
Return "-"c & outputdollars(Math.Floor(Math.Abs(number) - 0) + "") + outputcents(Math.abs(number) - 0);
Else
Return outputdollars(Math.Floor(number - 0) + "") + outputcents(number - 0);
End If
//格式化金额
function outputdollars(number) as 类型
If True Then
If number.length <= 3 Then
Return (number = "" ? "0"c : number);
Else
Dim [mod] As var = number.length Mod 3
Dim output As var = ([mod] = 0 ? "" : (number.substring(0, @mod)));
For i = 0 To Math.Floor(number.length / 3) - 1
If ([mod] = 0) AndAlso (i = 0) Then
output += number.substring([mod] + 3 * i, 3)
Else
output += AscW(","c) & number.substring([mod] + 3 * i, 3)
End If
Next i
Return (output)
End If
End If
End If
End If
function outputcents(amount) as string
If True Then
amount = Math.Round(((amount) - Math.Floor(amount)) * 100)
Return (amount < 10 ? ".0" + amount : "."c + amount);
End If
上面的代码是机器转的,错误不少,你自己修改一下吧。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询