ReportItems Expression : Data Type conversion

The other day, I am trying to create a report which uses a table. I have typed manually each cell.

In the subtotal lines, on rows, I had used ReportItems expression. On rows it was working.  However, on column, for "Qtr1-08", the same ReportItems expression, instead of adding the values, it was concatenating.

image

The report does not use any data from any table, i.e. no dataset. However, since I am using a table item, it needs a dataset so I cheated and created a dummy dataset with a dummy query as below:

image

What I was missing in the expression was the data type conversion. After, I converted the ReportsItem value to double using cdbl function, it came okay as below:

image

I modified the expression as below:

=cdbl(ReportItems!textbox23.Value) + cdbl(ReportItems!textbox27.Value) + cdbl(ReportItems!textbox24.Value)

Below is the list of conversion functions which we can use in VB .NET.

CBool - use this function to convert to Bool data type
CByte - use this function to convert to Byte data type
CChar - use this function to convert to Char data type
CDate - use this function to convert to Date type
CDbl - use this function to convert to Double data type
CDec - use this function to convert to Decimal data type
CInt - use this function to convert to Integer data type
CLng - use this function to convert to Long data type
CObj - use this function to convert to Object type
CShort - use this function to convert to Short data type
CSng - use this function to convert to Single data type
CString - use this function to convert to String data type

The better option is to use .NET CLS compliant alternative, i.e. System.Convert class. The key conversion methods supported by this class are:

ToBoolean - Converts a specified value to an equivalent Boolean value.
ToByte - Converts a specified value to an 8-bit unsigned integer.
ToChar - Converts a specified value to a Unicode character.
ToDateTime - Converts a specified value to a DateTime.
ToDecimal - Converts a specified value to a Decimal number.
ToDouble - Converts a specified value to a double-precision floating point number.
ToInt16 - Converts a specified value to a 16-bit signed integer.
ToInt32 - Converts a specified value to a 32-bit signed integer.
ToInt64 - Converts a specified value to a 64-bit signed integer.
ToSByte - Converts a specified value to an 8-bit signed integer.
ToSingle - Converts a specified value to a single-precision floating point number.
ToString - Converts the specified value to its equivalent String representation.
ToUInt16 - Converts a specified value to a 16-bit unsigned integer.
ToUInt32 - Converts a specified value to a 32-bit unsigned integer.
ToUInt64 - Converts a specified value to a 64-bit unsigned integer.

So remember to convert the data type of ReportItems expression so that it instead of concatenating, it would work as intended.

13 comments:

Anonymous said...

Thanks for writing this.

elakkeya yadhavan said...




My cousin recommended this blog and she was totally right keep up the fantastic work!










Data Conversion Services India

Anonymous said...

Hi there! I know this is kinda off topic but I was wondering
which blog platform are you using for this site? I'm getting fed up of Wordpress because I've had problems with hackers and I'm looking at options for another platform. I would be great if you could point me in the direction of a good platform.

Feel free to surf to my web blog :: click here to read more

Anonymous said...

Hi there, its pleasant paragraph on the topic of media print, we all know media is a wonderful source
of information.

my weblog: visit
my web site: the Porn photos

Anonymous said...

I do believe all of the ideas you have presented for your post.
They are really convincing and will definitely work.
Still, the posts are very brief for beginners. May just you
please lengthen them a little from subsequent time?
Thank you for the post.

Also visit my homepage: visit

Anonymous said...

Hello, Neat post. There is a problem together with your web site in web explorer, might test this?
IE still is the market leader and a huge component of folks will pass over your fantastic writing due
to this problem.

Here is my site :: http://pornharvest.com/index.php?q=Professional+Porn&f=a&p=a

Anonymous said...

Hey there, You have done a great job. I'll certainly digg it and personally recommend to my friends. I am sure they'll be benefited
from this site.

My site :: see more

Anonymous said...

I know this if off topic but I'm looking into starting my own blog and was wondering what all is required to get setup? I'm assuming having a
blog like yours would cost a pretty penny? I'm not very web savvy so I'm not 100% positive. Any tips or advice would be greatly appreciated. Appreciate it

Feel free to surf to my web blog Email Console

Anonymous said...

I'm really enjoying the theme/design of your web site. Do you ever run into any internet browser compatibility issues? A handful of my blog audience have complained about my site not operating correctly in Explorer but looks great in Firefox. Do you have any tips to help fix this issue?

Also visit my site this post

Anonymous said...

Howdy very cool site!! Guy .. Excellent .. Superb ..
I will bookmark your website and take the feeds additionally?
I am satisfied to find a lot of helpful information here within
the post, we want work out extra techniques in this regard, thanks
for sharing. . . . . .

My homepage: natural cellulite treatment

Anonymous said...

Great beat ! I would like to apprentice even as you amend your site, how could i subscribe for a blog site?
The account aided me a appropriate deal. I were tiny bit familiar of this your broadcast offered bright transparent
concept

Look at my page :: simply click For source - theloungeroom.tk

Anonymous said...

No matter if some one searches for his required thing,
therefore he/she desires to be available that in detail,
therefore that thing is maintained over here.


My blog :: http://pornharvest.com/index.php?m=2084297

Anonymous said...

There's certainly a great deal to know about this topic. I like all of the points you made.

My web blog :: iveta soft spoken