473,372 Members | 1,055 Online

# 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 1402

"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 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: Faith0G | last post by: I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be... 0 by: isladogs | last post by: The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former... 0 by: ryjfgjl | last post by: In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import... 0 by: aa123db | last post by: Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function \$name\$ (\$parameters\$) { } ... 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... 0 by: emmanuelkatto | last post by: Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel 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...