Need to format into a decimal

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vertigo262
    New Member
    • Jul 2007
    • 62

    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).Ro ws(0)("RatingSu m").ToString ()
    Dim columncount As Integer = Ds.Tables(1).Ro ws(0)("columnco unt").ToString( )

    Dim Rating As Integer = RatingSum / columncount

    Return Rating

    --------------------------------------------------------------------------------------------------
  • erlin
    New Member
    • Jul 2007
    • 5

    #2
    Dim RatingSum As Integer = Ds.Tables(0).Ro ws(0)("RatingSu m").ToString ()
    Dim columncount As Integer = Ds.Tables(1).Ro ws(0)("columnco unt").ToString( )

    Dim Rating As Integer = RatingSum / columncount

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

    Dim Rating as Double =RatingSum/Columncount

    Comment

    • vertigo262
      New Member
      • Jul 2007
      • 62

      #3
      Thank you erlin, that worked!

      all fixed

      Comment

      Working...