SSRS 交替使用数字格式的 1000 个分隔符

SSRS alternating 1000 separators with Number Format

我正在 Microsoft Report builder 中创建一个报告,据我所知,它在其表达式中使用了 MS Visual Basic,我目前遇到了一个奇怪的数字格式问题:

由于某些未知原因,要求将数字(范围从 10.00 到 10,000,000,000.00+)格式化如下:10.000,000.000,00 - 因此交替使用 1000 个分隔符和一个逗号作为小数点分隔符。较小的数字显然会有较少的分隔符,但它们的顺序不会改变。

有没有什么方法可以使用格式函数来做到这一点,或者我是否必须使用开关和子字符串函数来进行某种手动操作?

您可以使用自定义代码来创建格式化字符串

Public Function FormatNumber( num As Decimal) As String

Dim s1 As String
Dim s2 As String

' Format integer part using chars a and b
s1 = Format(  num, "###a###b###a###b###" )

' Remove unwanted a and b characters from begining

While s1(0) = "a" Or s1(0) = "b" 
s1 = Right(s1,Len(s1)-1)
End While

' Replace a and b characters
s1 = s1.Replace("a",",")
s1 = s1.Replace("b",".")

' Take decimal part and format it as two digits
s2 = Format ( ((num Mod 1)*100) \ 1, "00" )

Return s1 + "," + s2

End Function

现在在你的字段上使用以下表达式

=Code.FormatNumber(Fields!val.Value)