0

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!! :)

user2572833
  • 146
  • 11
  • What happens when you try? Are you getting an error? – Tab Alleman Jun 23 '15 at 18:15
  • @TabAlleman function 1 works. function 2 does not know how to make a call to the first functions returned value. In other words, I don't know how to pull the value returned by the Display function into the BoldText function. The BoldText function errors out because ValueOfMyParameter is not defined. – user2572833 Jun 23 '15 at 18:35

1 Answers1

1

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)
Trubs
  • 2,829
  • 1
  • 24
  • 33
  • That is the solution I was looking for, but is there any way to make it so that it is not case-sensitive? With the above code, "Bob" and "bob" are not equal. – user2572833 Jun 24 '15 at 11:55
  • Adding ToLower() to the returned Text and Param strings worked, but I lose the case formatting of the field. Is there any way to do the comparison and keep the field's case the same? – user2572833 Jun 24 '15 at 12:34
  • There are some options for case insensitivity here http://stackoverflow.com/questions/244531/is-there-an-alternative-to-string-replace-that-is-case-insensitive – Trubs Jun 24 '15 at 21:16