locked
How can i capitalize the first character in a report RRS feed

  • Question

  •  

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

    Karen

    Tuesday, September 4, 2007 7:43 PM

Answers

  • 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

    Tuesday, September 4, 2007 8:30 PM

All replies

  • It is advisable to do it in the backend database.

     

    --Imran

     

    Tuesday, September 4, 2007 8:10 PM
  • 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

    Tuesday, September 4, 2007 8:30 PM
  • 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

    Tuesday, September 4, 2007 8:48 PM
  •  

    Convert the value you to String.

     

    ex:

    =Code.ConvertToCamelCase("STRING VALUE")

     

    Hope this helps.....

    Tuesday, September 4, 2007 9:20 PM
  •  

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

    Wednesday, September 5, 2007 12:16 AM
  • 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

    Wednesday, September 5, 2007 1:20 PM
  •  

    Did this answer your question ?

     

    Thursday, September 6, 2007 3:44 PM
  •  

    Yes and No... But yeah i solved it... thanks a lot..
    Thursday, September 6, 2007 3:50 PM
  • 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

    Thursday, September 6, 2007 4:00 PM
  •  

    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

    Thursday, September 6, 2007 4:03 PM
  • Hi Deepak,

    How can I use C# Function. VB Code is Running sucessfully but when I write C# Method it through ' There is an error on line 0 of custom code: [BC30183] Keyword is not valid as an identifier.' Compile time Error.I am using RDLC which Bundled with VS2005.

     

     

    Mahesh
    Friday, May 2, 2008 5:48 AM
  • Hello Rastogi,

    Where are you writing your C# code? In a C# class file or in the reports Code window?

     

    You cannot use C# code in the Code Window. You have to create a class file and refer that class file as an assembly in the reference section of the Report--> Properties widow.

     

    The link below explains everything,

     

    http://msdn.microsoft.com/en-us/library/ms153561.aspx

     

    Hope this helps...

     

    Deepak

    Friday, May 2, 2008 12:57 PM
  •  ishahk wrote:

    It is advisable to do it in the backend database.

     

    --Imran

     

     

    I dont agree, in general it is always advisable to do formating on the client.

    Friday, May 2, 2008 1:15 PM