473,395 Members | 1,460 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Need to format into a decimal

Hello,

I am trying to pull data from a database which are integer values,

and dive them and return a decimal or a percent really.

My code seems to round the number up or down.

for example if I have a Colmuncount of 3 and a sum of 8

the return value is 3 when it should be 2.6.

how do a format my code to display the value in decimal places.

any help is appreciated.

------------------------------------------------------------------------------------------
Dim RatingSum As Integer = Ds.Tables(0).Rows(0)("RatingSum").ToString()
Dim columncount As Integer = Ds.Tables(1).Rows(0)("columncount").ToString()

Dim Rating As Integer = RatingSum / columncount

Return Rating

--------------------------------------------------------------------------------------------------
Aug 2 '07 #1
2 1064
erlin
5
Dim RatingSum As Integer = Ds.Tables(0).Rows(0)("RatingSum").ToString()
Dim columncount As Integer = Ds.Tables(1).Rows(0)("columncount").ToString()

Dim Rating As Integer = RatingSum / columncount

Return Rating
-------
Change the datatype of "Rating" from Integer to "Double"...

Dim Rating as Double =RatingSum/Columncount
Aug 2 '07 #2
Thank you erlin, that worked!

all fixed
Aug 3 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: J | last post by:
Would anyone know if there a type tag to format a double? I have f for floating point, but cannot find one for double.
0
by: Tobias | last post by:
Hi all, is it possible to set decimal-format in any way by using a variable or similar? Example: <xsl:variable name="myseparator" select="@separator"/> <xsl:decimal-format...
1
by: Mike MacSween | last post by:
This looks like a bug to me. I have an expression on a report: =Format(Sum((**)*(/)),"0.00") Score is byte PercentOfGrade is double PropDegree is single ModuleCats is byte
1
by: Terencetrent | last post by:
I am trying to format a query expression drawn from a dialog box as percent. The original statement to get the value for the query is as follows: New%markup: !! The dialog box looks the...
2
by: Hers2keep | last post by:
I have the following control on a report: "Total " & & " " & & " -- " & Format$(Sum(),"Standard") I can't use the simple way because of the concatenated fields. How can I force no decimal...
7
by: Alpha | last post by:
Hi, I'm maintaining C# code and am fairly new with C# programming. I'm looking for codes that's droping the 2nd digit of a nuber printed out and I suspect it's the code below. Can someone tell me...
5
by: Robin Tucker | last post by:
My database has a column for numeric data items. How can I use this number in the "format" command, such that for, say precision 2, I get numbers like 2011.01 or 2387.00 and for 4 I would get...
2
by: AMDRIT | last post by:
Hello Everyone, I would like to format the Display Members of a combobox's datasource. Is there a way to apply a format without subclassing the original datasource? For example, given a list of...
2
by: hunslair | last post by:
This is a really basic question. I am taking a teach yourself beginners course on Access 2003 and have run into a road block on one practice. In a select query, I have created a simple calculation...
3
by: =?Utf-8?B?THVpZ2k=?= | last post by:
Hi all, with this code: decimal? test = 1200345.56m; decimal? test2 = Decimal.Parse(String.Format("{0:0,0.000}", test)); i can not obtain a decimal value with thousands separators (but...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.