Click here to Skip to main content
15,891,708 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
SQL
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
C#
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

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
 
Share this answer
 
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900