reporting-servicescustom-code

Formatting particular text within SSRS


I have two pieces of code that I would like to try to join together:

1.

Public Function DisplayAParameterValue(ByVal parameters as Parameters) as Object
    Return parameters("MyParameter").Value
End Function

2.

Function BoldText(Text As String) As String
   Return Text.Replace("ValueOfMyParameter", "<b>ValueOfMyParamter</b>)
End Function

The first bit of code will return the value of the parameter "MyParameter." I then want to run that value through the second bit of code so that when I make a call to the function, it will bold any instances of my parameter's value.

Any help is greatly appreciated!! :)


Solution

  • DisplayAParameterValue provides less utility than simply using Parameters!MyParam.Value, so if you actually need this function, could you provide a use-case?

    But to achieve your desired outcome you could

    Function BoldParameterText(Text As String, Param as String) As String
       Return Text.Replace(Param, "<b>"+Param+"</b>")
    End Function
    

    and call it using below

        =code.BoldParameterText(First(Fields!myResult.Value, "MyDataSet"),Parameters!MyParam.Value)