Monday, March 26, 2012

How can i capitalize the first character in a report

How can i capitalise the first character in a report ... Regards

Karen

It is advisable to do it in the backend database.

--Imran

|||

The same question was asked long time back by somebody and I found this answer here in this forums.

I remember this was answered by Rajiv and Jarret. Thanks to them.

1.) Add this function in Code section.

Public Function ConvertToCamelCase(inputStr) as String
dim inputStrArr
dim tempWord
dim outputStr
dim i
inputStrArr = Split(inputStr, " ")

for i = 0 to UBound(inputStrArr)
tempWord = inputStrArr(i)
tempWord = UCase(Left(tempWord, 1)) & LCase(Right(tempWord, len(tempWord) - 1))
if outputStr = "" then
outputStr = tempWord
else
outputStr = outputStr & " " & tempWord
end if
Next

return outputStr
End Function

2.) Put this line of code in the expression you want.

=Code.ConvertToCamelCase(Fields!SomeText.Value)

Hope this helps...

Deepak

|||

Deepak....

Thanks for the answer.. when i run it i am getting an error saying

The Value expression for the textbox ‘textbox1’ contains an error: Argument 'Length' must be greater or equal to zero.

What should i do?

Regards

Karen

|||

Convert the value you to String.

ex:

=Code.ConvertToCamelCase("STRING VALUE")

Hope this helps.....

|||

Deepak,

i am displaying the information like this in the text box

all contribution, pre-tax contribution, etc....

so what do u think i should do....

|||

Karen,

Use this expression below in your textbox. Remember to give a space after the Comma or change the function code accordingly.

=Code.ConvertToCamelCase("all contribution, pre-tax contribution, tax contribution, red, yellow, pink panther")

Hope this helps..

Deepak

|||

Did this answer your question ?

|||Yes and No... But yeah i solved it... thanks a lot..|||

Can you please detail me what changes did you make to accomplish this task or what did you do. I am sorry if I am troubling you, I am just intrested to learn more.

--Deepak

|||

Actually i didnt do much change .... Tried using that logic directly in my stored procedure and it worked fine... But i ran into a user problem that they wanted Some Words to be a capitalised and some not to later on... so i ended up changing them in the database itself... Thanks a lot for your help

Regards

Karen

No comments:

Post a Comment