Custom Code textrun contains an error: Name 'Function' is not declared

  • 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

  • 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

  • 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.

  • 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