Click here to Skip to main content
14,356,490 members
Rate this:
Please Sign up or sign in to vote.
See more:
hi
I am implementing a
Formula
in vb.net

The Problem is I am doing as Follows

In SQl Statement

when I am Executing
this Formula
select (CONVERT(INT,(12-11)/2)*0.05+0.75)

i am getting out put

.75

but my problem is that when I am implementing the same
in vb.net
as
Dim frm As Decimal = ((12 - 11) / 2) * 0.05 + 0.75

i am not getting the Same
am getting
0.775
as output

but i want the same output as SQL
please assist where i am missing.
Posted

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

The SQL at
CONVERT(INT,(12-11)/2)
evaluates to 0 which is causing the result to be 0.75. Whearas the VB.net statement evaluates the same to 0.5.

If the SQL behavior is the intended then you can use the following code.

Dim frm As Decimal = (CInt((12 - 11) / 2)) * 0.05 + 0.75
   
Comments
Karwa_Vivek 22-Apr-13 8:22am
   
Thanks for help

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100