473,471 Members | 4,650 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Storing and reading decimal numbers

65 New Member
Hi,

I've got some code in VBA where I calculate some numbers. Now some of them are large decimal numbers like -6,3216324E03. So in scientific notations. Now I need to add them to a table with an insert query.

The query:
db.Execute ("INSERT INTO tmpZscore (datum, leeftijd, lengte, ZscoreL, gewicht, ZscoreW, BMI, ZscoreB, IBW) VALUES('" & CStr(dag & "/" & maand & "/" & Jaar) & "','" & test & "','" & CStr(lengte) & "'," & CDbl(scoreL) & ",'" & CStr(gewicht) & "','" & CStr(scoreW) & "','" & CStr(bmi) & "','" & CStr(scoreB) & "','" & Mid(CStr(ibw), 1, 6) & "%');")

I had already casted everything to string because it was easier to store decimal numbers that way. But now I need to store them as numbers because of the scientific notation. Otherwise I've got a problem in displaying these numbers in a report.
It would give -6,32 instead of -0,00632. I need the second one but I can't reformat the number if I don't have it as a number ofcourse.

Second problem: I've got my numbers in normal european format (5.000,236). So a comma for decimal seperator and a point for displaying. Now I can't get this number written in a tabl because of the comma. But when I change my regional settings to a point for decimal seperator all my numeric values in my table aren't correct anymore. Anyone who's got a solution for this to store decimal values with comma in a tabel.

Greetz

Twanne
Jul 30 '07 #1
1 3423
Twanne
65 New Member
Apperantly it wasn't so hard.

For the ones who are going to stumble on this problem:

Just keep working like you are, don't change any regional settings. This gets messed up when you have decimal numbers with a comma already stored in your database. (7,03 becomes 703 for example)

Secondly to store the numbers you make sure your fields are in Double Precission, and your numbers are of the type double.

Then when you want to insert them into the table you use:

INSERT INTO bleh (First) VALUES ('" & CDbl(numer) & "');

Note the single quote before and after the double quotes placed around the number. I don't know why for sure but this way SQL doesn't comes to complain about a wrong amount of fields.

I'm sure there are other ways to this but this work for me so I'm very happy now.

Greetz

Twanne
Jul 30 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: Batista, Facundo | last post by:
Here I send it. Suggestions and all kinds of recomendations are more than welcomed. If it all goes ok, it'll be a PEP when I finish writing/modifying the code. Thank you. .. Facundo
17
by: John Bentley | last post by:
John Bentley: INTRO The phrase "decimal number" within a programming context is ambiguous. It could refer to the decimal datatype or the related but separate concept of a generic decimal number....
7
by: Carl G | last post by:
I have a DataSet with a couple of tables. I have noticed that when I am trying to store a Decimal 0.000 in a datarow, the value is changed to 0, without the information about its decimalplaces. ...
10
by: David Casey | last post by:
I'm working on a program for my C++ class and have it all written and working except for one part. I need to compare two numeric variables to determine decimal accuracy between them. For example:...
3
by: Tanuki | last post by:
Hi All: I encounter a programming problem recently. I need to read a binary file. I need to translate the binary data into useful information. I have the format at hand, like 1st byte = ID,...
6
by: KevinD | last post by:
assumption: I am new to C and old to COBOL I have been reading a lot (self teaching) but something is not sinking in with respect to reading a simple file - one record at a time. Using C, I am...
2
by: Steve Summit | last post by:
-----BEGIN PGP SIGNED MESSAGE----- It's often explained that the reason for some of the imprecision in C's definition is so that C can be implemented on different kinds of machines -- say, those...
9
by: jeff M via .NET 247 | last post by:
I'm still having problems reading EBCDIC files. Currently itlooks like the lower range (0 to 127) is working. I have triedthe following code pages 20284, 20924, 1140, 37, 500 and 20127.By working I...
11
by: Pieter | last post by:
Hi, I'm having some troubles with my numeric-types in my VB.NET 2005 application, together with a SQL Server 2000. - I first used Single in my application, and Decimal in my database. But a...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
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: 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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.