473,473 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DATATYPE PROBLEM(cross)

I have a column in my table BizdekiFiyat . The datatype = float length =8
(to save money values).. It is impossible to change these attributes for
some reasons.

It has records like This

BizdekiFiyat
110
24
29.5
31.35
I use Vb.Net . I use ExecuteReader To select values from my db..

After first attemp

Dim BizdekiFiyat As Integer OR Dim BizdekiFiyat As Decimal
IT returns
110
24
295
3135

Dim BizdekiFiyat As String
It returns right results.

110
24
29.5
31.35

There is a problem with decimal records when i want to evaluate this
values..

For example
Dim BizdekiFiyat As String
BizdekiFiyat = BizdekiFiyat * 1.05

It is supposed to be
29.5 * 1.05 =30.975
31.35*1.05=32.9175
but it returns
309,75
3291,75

How can i solve this problem ?



Feb 11 '06 #1
1 968

"Savas Ates" <in da club> wrote in message
news:OE*************@TK2MSFTNGP14.phx.gbl...
I have a column in my table BizdekiFiyat . The datatype = float length =8
(to save money values).. It is impossible to change these attributes for
some reasons.
Dim BizdekiFiyat As Integer OR Dim BizdekiFiyat As Decimal
IT returns
110
24
295
3135
Integer datatype will always truncate your decimal fraction values.

I've had data dimension problems trying to use the Decimal datatype for
holding (SQL) decimal data returned through parameters using MS's EntLib
DAAB. I resolved this by using .NET's Double datatype (though I'd prefer to
know why .NET's decimal gave me the problem in the first place).
Dim BizdekiFiyat As String
It returns right results.
Because the value is being represented and stored as a string (just like
typing into a textbox), not a numeric type, so...
There is a problem with decimal records when i want to evaluate this
values..

For example
Dim BizdekiFiyat As String
BizdekiFiyat = BizdekiFiyat * 1.05

How can i solve this problem ?


You're expecting .NET to intelligently convert your datatypes for you, which
it is valiantly trying to do. You should consider setting Option Strict on
(Tools | Options | Projects | VB Defaults) to prevent loose data typing and
late binding. You should strongly type your datatypes as a matter of god
practice. When you need to convert datatypes, dothis explicitely using
CType(sourceObj, targetType), or the shorthand versions such as Cint(value),
CDbl(value), etc.

As for your calculations: e.g. using Double to store your values, create a
function which you'll call when necessary to do your calculations:

private function MultiplyBizdekiFiyat(Byval origValue as double, Byval
MultiplyBy as double) As Double
'Perform the calculation
MultiplyBizdekiFiyat = origValue * MultiplyBy

'Return the value to the calling method.
return MultiplyBizdekiFiyat

end function

Hope that helps

Al
Feb 11 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: WhiteRavenEye | last post by:
Why can't I subclass any window except mine in VB? Do I have to write dll for this? I've tried to subclass it with SetWindowLong but without success... Does anyone know how to subclass window...
1
by: Andy | last post by:
I am building a large enterprise application and which to implement a nested namespace hierarchy across the application. My problem is that when I declare an assembly "MyApp.DataTypes" in one...
0
by: Savas Ates | last post by:
i have 3 class.. Dim ws As New WebReference1.ProductDefinitionType() i can write this class's variables like this
23
by: Jeff Rodriguez | last post by:
Here's what I want do: Have a main daemon which starts up several threads in a Boss-Queue structure. From those threads, I want them all to sit and watch a queue. Once an entry goes into the...
1
by: Troy Jerkins | last post by:
Sorry for the cross post, but I'm stumped. I'm trying to render the XML content that is stored as an image datatype in the SQL Server Reporting Services database.Table Catalog, Content Colmn,...
4
by: Thomas F.O'Connell | last post by:
Since the current stable version of postgres (7.4.x) doesn't allow cross-datatype comparisons of indexes, is it always necessary to cast my application data explicitly in order for an index to be...
1
by: Savas Ates | last post by:
i wanna to transffer 2000 data from my mdb file to a web service... i used DataReader object ... and also in proxy class i used some arrays... im getting this error Server Application...
1
by: Savas Ates | last post by:
I have a column in my table BizdekiFiyat . The datatype = float length =8 (to save money values).. It is impossible to change these attributes for some reasons. It has records like This ...
11
by: Jake Langham | last post by:
A program I'm writing requires a 64-bit datatype. On gcc 4.1.1 I can compile with 'long long' integers but I'm aware that this is not an ANSI standard type and am worried about portability issues -...
3
by: xdli888 | last post by:
I have two classes , say A and B. A contains methods named f1() , f2() and B contains methods named g1(), g2(). f1() will invoke g2() and g1() will invoke f2(). This situation is kinda like two...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.