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.