473,770 Members | 3,398 Online
Bytes | Software Development & Data Engineering Community
+ 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.9 175
but it returns
309,75
3291,75

How can i solve this problem ?



Feb 11 '06 #1
1 1424

"Savas Ates" <in da club> wrote in message
news:OE******** *****@TK2MSFTNG P14.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 MultiplyBizdeki Fiyat(Byval origValue as double, Byval
MultiplyBy as double) As Double
'Perform the calculation
MultiplyBizdeki Fiyat = origValue * MultiplyBy

'Return the value to the calling method.
return MultiplyBizdeki Fiyat

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
2733
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 ANY window in VB? Thanks...
1
1268
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 assemby and then another "MyApp.GUITypes" in another I cannot access types in the "...DataTypes" namespace from the Assembly containing the "...GUITypes" namespace. The documentation suggests this should be possible. Do I need to use aliases.
0
998
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
1565
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, using ASP.NET (VB.NET). These look to tbe the RDL files that get uploaded where the TYPE column = 2 in the Catalog Table. What happens is, the xml gets rendered in IE (6.0) but is truncated at the end because it is not well-formed. It seems most...
4
1237
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 used, even among the integer types? E.g., If I have a table with a bigint primary key and application data compared against that primary key, must I always explicitly cast the application data to bigint if I want postgres to use the index? ...
1
2972
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 Unavailable The web application you are attempting to access on this web server is currently unavailable. Please hit the "Refresh" button in your web browser to retry your request.
1
940
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 BizdekiFiyat 110 24 29.5
11
5652
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 - especially on 32-bit machines. Since I can't seem to find this sort of information anywhere: is there a particular datatype I should be using and how do I ensure that I choose the correct datatype for each machine? Cheers, -Jake
3
5774
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 things interact with each other. But the program couldn't pass the compliation. g++ says " invalid use of undefined type of ......" . As far as I know, forward declaration couldn't solve this problem, and I have tried. Both of the definition of...
0
9425
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10057
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9869
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7415
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5312
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3970
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 we have to send another system
2
3575
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2816
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.