Unrecognized identifier error in custom code

Hello all,
I've made a Report porting from SS2008 to SS2008.
In a textbox I use a:

Number -> Custom Format

like these:

=Code.FormatString(Fields!NumDecRpt.Value)

but gives me the "Unrecognized identifier" red squiggle.

My FormatString function (in the rdl file) is this:


Public Shared Function FormatString(ByVal Decimals as object) As String
  dim format = "N0"
  if not (Decimals is nothing or Decimals is System.DBNull.Value) then
    dim decs as integer
    decs = Convert.ToInt32(Decimals)
    if decs>0 then
      format = "N"+decs.ToString()
    end if
  end if
  return format
End Function

What's wrong with this?


Luis

September 11th, 2013 10:07am

Hi,

I am not sure where the code is just like this in the code window or when you copy pasted here, it became like this. Please check the "greeter than" sysmbol in if condition. It should be if decs > 0 then.

I used the same code with the if condition changed and it worked.

Regards

Srini 

Free Windows Admin Tool Kit Click here and download it now
September 11th, 2013 11:59am

Hi Srini,
I've tried, but not changes.

Luis
September 11th, 2013 12:16pm

Hi Ciupaz,

You didn't specify the data type for variable Format.

dim format = "N0"

Try

dim format as String = "N0"

Then I would replace  if decs>0 then

with if decs > 0 then

I would replace (Decimals is nothing or Decimals is System.DBNull.Value)

with (Decimals is nothing)

Thanks.

Free Windows Admin Tool Kit Click here and download it now
September 11th, 2013 1:14pm

Hi Luis,

Can you give me a sample of your number format, so that i can rewrite the your function and give you the same.

Input Number format:?

Expected Number Format:?

Thanks & Regards,

September 11th, 2013 1:15pm

 Is it based on the NumDecRpt field values,
that can be 0 or 1 or 2 or 3 (and is set by code).
Then I set the Number -> Custom Format for
my textbox.

Free Windows Admin Tool Kit Click here and download it now
September 11th, 2013 1:30pm

Hi Ciupaz,

You didn't specify the data type for variable Format.

dim format = "N0"

Try

dim format as String = "N0"

Then I would replace  if decs>0 then

with if decs > 0 then

Thanks.

September 11th, 2013 1:33pm

I updated my post. Please re-read it.
Free Windows Admin Tool Kit Click here and download it now
September 11th, 2013 7:38pm

Now I've written my function in this way:


Public Shared Function FormatString(ByVal Decimals as object) As String
  dim format as string = "N0"
  if not (Decimals is nothing) then
    dim decs as integer
    decs = Convert.ToInt32(Decimals)
    if decs>0 then
      format = "N"+decs.ToString()
    end if
  end if
  return format
End Function

but still shows the red squiggle line in


=Code.FormatString(Fields!NumDecRpt.Value)


L

September 12th, 2013 7:33am

Hi Ciupaz,

It's normal that there will be red underline under the function name when we reference a custom code in an expression. This behavior is by design. Please understand that it doesn't affect the execution of the expression at all. I have tested the code in your last post, it works without any error. Please just go ahead and let us know if the report returns any error at runtime.

Regards,
Mike Yin

If you have any feedback on our support, please click here

Free Windows Admin Tool Kit Click here and download it now
September 12th, 2013 9:41am

Ah, ok, (is it a good design though?).
Thanks a lot Mike.

Luis

September 12th, 2013 9:59am

The question is too complicated.
Free Windows Admin Tool Kit Click here and download it now
June 18th, 2015 11:46pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics