?
Solved

larger numbers

Posted on 2003-02-27
13
Medium Priority
?
193 Views
Last Modified: 2010-05-01
what field type can i use to store a very very large number.

i want to multple this number by 3

3990000070756820

so the number ends up to be:

11970000212270460

but i get a number like this:

4.19700002122705E+16

ideas...
0
Comment
Question by:tomhoran
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 2
13 Comments
 
LVL 2

Expert Comment

by:Jacamar
ID: 8039563
declare that variable as a double.  It can be very large.
I think a textbox would work as good as anything to enter that number in.
0
 

Author Comment

by:tomhoran
ID: 8042282
but i end up with a number like this

1.25910000636811E+17
0
 
LVL 2

Expert Comment

by:Jacamar
ID: 8042522
doubles can go up to plus or minus

1.8 E+308

What is the problem?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:Jacamar
ID: 8042538
if you don't want the number to be displayed like that, do this.

Picture1.Print Round(Variablename, 3)

That will round to 3 decimal places
0
 

Author Comment

by:tomhoran
ID: 8042776
what i'm really looking to do is:

WkAcctNo = WkAcctNo * 3
WkAcctNo = WkAcctNo / 2

then store the results in a varchar data field as whole number string like

123456789123123

not

1.123123+18

Thanks
0
 
LVL 2

Expert Comment

by:Jacamar
ID: 8042909
oh, i gotcha,  give me a couple min
0
 
LVL 2

Expert Comment

by:Jacamar
ID: 8042997
Unfourtunately the double variable type only goes up to 15 or 16 significant digits.  I am not aware of a way that will solve your problem.  
0
 
LVL 3

Expert Comment

by:PNJ
ID: 8043016
Try format$(WkAcctNo,"#")

Eg:
?  12.34e16
 1.234E+17
?  format$(12.34e16,"#")
123400000000000000
0
 

Author Comment

by:tomhoran
ID: 8043222
the format does it but your right it's truncating the number after the multiplication. isn;t there any other number types? i tried varant, but that didn't work.
0
 
LVL 3

Accepted Solution

by:
PNJ earned 300 total points
ID: 8043350
Try "Help Decimal" It says:

Decimal variables are stored as 96-bit (12-byte) unsigned integers scaled by a variable power of 10. The power of 10 scaling factor specifies the number of digits to the right of the decimal point, and ranges from 0 to 28. With a scale of 0 (no decimal places), the largest possible value is +/-79,228,162,514,264,337,593,543,950,335. With a 28 decimal places, the largest value is +/-7.9228162514264337593543950335 and the smallest, non-zero value is +/-0.0000000000000000000000000001.

Note   At this time the Decimal data type can only be used within a Variant, that is, you cannot declare a variable to be of type Decimal. You can, however, create a Variant whose subtype is Decimal using the CDec function.

Is that big enough?

Sub Test()
   Dim ATest As Variant
   ATest = CDec("3990000070756820")
   ATest = ATest * 3
   Debug.Print Format$(ATest, "#")
   Exit Sub
End sub

test
11970000212270460

Yup, that does it.
0
 

Author Comment

by:tomhoran
ID: 8043760
were getting close. it's rounding.

xx = 13990000070756820 * 3

xx should = 41970000212270460

but VB returns 41970000212270500  

it's rounding the 460 to 500? Why?
0
 

Author Comment

by:tomhoran
ID: 8043798
never mind i think i got it, hold on
0
 

Author Comment

by:tomhoran
ID: 8043823
Thanks for everyones help .. here is the working code:


Dim WkAcctNo As Variant

WkAcctNo = CDec(WkAcctNo)
WkAcctNo = WkAcctNo * 3
WkAcctNo = WkAcctNo / 2
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question