Click here to Skip to main content
15,893,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

try this

SQL
For i As Integer = 0 To str.Length - 1
    If i = 3 Then
        str = str.Insert(i, " ")
    End If
Next
 
Share this answer
 
Comments
umarbangash 8-Apr-11 3:05am    
Thnx... U rang my bell :-)

I excluded the loop though and directly put 3 instead of i... And then I reset the datatable column value and sent it to report!

Dim Str As String = dt.Rows(0)("CardNo").ToString()
Str = Str.Insert(3, " ")
dt.Rows(0)("CardNo") = Str
Mahendra.p25 8-Apr-11 3:07am    
great...
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[^]
 
Share this answer
 
Comments
umarbangash 8-Apr-11 3:06am    
thnx for the suggestion :-) I didnt try it though coz I think it is difficult for me to do! but thnx :-)
Wendelius 8-Apr-11 13:12pm    
You're welcome

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900