January 13, 2011 at 6:06 pm
I've written the following vb.net code first in vs.net to test it and then copied it into the code box in my report. I'm now getting the error in the subject and have no idea why. Can anyone see anything in this that would cause a problem?
Public Shared Function FormatSubmitter(ByVal submitterName As String) As String
Dim count As Integer = 0
Dim i As Integer
' Get the number of times the ';' char occurs in the string.
For i = 0 To submitterName.Length - 1
If submitterName(i) = ";"c Then
count += 1
End If
Next
' Remove multiple occurances of ';'.
If count > 1 Then
For i = 0 To submitterName.Length - 1
If submitterName(i) = ";"c Then
submitterName = submitterName.Insert(i + 1, ", ")
End If
Next
' After inserting ", " then replace all occurances of ';'.
submitterName = submitterName.Replace(";", "")
' Finally remove the last occurance of ", " that was added in the loop.
submitterName = submitterName.Remove(submitterName.Length - 1, 1)
Else
' When there is only one occurance of ';' then remove it.
submitterName = submitterName.Replace(";", "")
End If
Return submitterName
End Function
January 14, 2011 at 1:43 am
Hi Journeyman,
I don't see anything wrong with your code. Just copied it into a new report and it works like a charm. I'll try to attach my test rdl file.
Kind regards,
Linda
January 14, 2011 at 10:21 am
Thank you so much for checking my code. At least I know the code is good. I did just walk into work this morning and find my typo. My fault. I guess I just needed to sleep on it.
I didn't have the Code. part ahead of the function name. Silly mistake.
Thanks again.
January 18, 2011 at 1:36 am
You're welcome.
It's always the little things that you search for the longest.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply