在.rdlc报告中的字符串中添加空格

问题描述:

我正在VB.Net中使用.rdlc报告

我从数据库中获取了7个字符的varchar值.字符就像"5647912".现在,在报告中,我想向他们显示这样的"564 7912".我该怎么做?

当前我正在使用"= First(Fields!CardNo.Value)"如何获得所需的结果?

谢谢

I am using .rdlc reports in VB.Net

I am getting a 7 chars varchar value from database. The characters are like "5647912". Now in the report I want to show them like this "564 7912". How do I do this??

Currently I am using "=First(Fields!CardNo.Value)" How can I achieve my desired result??

Thanks

尝试此

try this

For i As Integer = 0 To str.Length - 1
    If i = 3 Then
        str = str.Insert(i, " ")
    End If
Next


如果字符串包含数字,我认为最简单的方法是首先将其强制转换为例如整数( ^ ])

然后使用数字格式模型 http://msdn.microsoft.com对其进行格式化/en-us/library/ms157406(v=SQL.100).aspx [
If the string contains numbers, I think the easiest way is to cast it first to for example integer (http://msdn.microsoft.com/en-us/library/ms141704.aspx[^])

And then format it using number format models http://msdn.microsoft.com/en-us/library/ms157406(v=SQL.100).aspx[^]