Solved

Very big: Long Addition...

Posted on 2002-03-19
8
192 Views
Last Modified: 2010-05-02
I have 16 digit max currency numbers,
I need to add these, but I cannot do it, because VB have no supported type for this... bigger than LONG.

   Both + and - values I have...

What Can I do for this? How can I add and display these correctly...

Sample:
Num1: 10,000,000,123
Num2: 15,000,000,450
I wanna add these two number...  (No .00)



0
Comment
Question by:Ege
8 Comments
 
LVL 39

Expert Comment

by:appari
ID: 6879258
if at all its required to do these type of calculations i do this in SQLs. for example in Oracle

select to_char(Num1+Num2) from dual

will return exact calculated value without truncation. then use the returned value and format it using format(returnval,"#,#0")

replace Num1 and Num2 with actual values
0
 
LVL 49

Accepted Solution

by:
Ryan Chong earned 200 total points
ID: 6879266
Use the currency data type?

optionally try the Double data type as:

Range of double is 1.7E +/- 308 (15 digits).
0
 
LVL 2

Expert Comment

by:ronenr
ID: 6879268
IF I undestand right you can do:

Dim x As Currency
Dim y As Currency

x = 10000000123#
y = 15000000450#

Debug.Print Format(x + y, "#,###")

The datatype currency and double are 8 bytes numbers.

Good luck
0
 
LVL 1

Author Comment

by:Ege
ID: 6879278
:)
I am happy today, and want to spent points! ...
Well, I am very new to VB, and do NOT know data types!

sorry others, it is FCEP... (First Come, Earn Point  like FIFO/FILO) :))

bye...
not: I gave "C" ryancys, It was easy...
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Expert Comment

by:Doodle
ID: 6879282
Use the double data type it can deal with larger values.

Integer 2 bytes     -32,768 to 32,767
Long    4 bytes     -2,147,483,648 to 2,147,483,647
Single  4 bytes    
       -3.402823E38 to -1.401298E-45 for negative
        1.401298E-45 to 3.402823E38 for positive
Double  8 bytes
  -1.79769313486232E308 to -4.94065645841247E-324 (-)      
     4.94065645841247E-324 to 1.79769313486232E308 (+)
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 6879292
> It was easy...
Thank for the points But is it me deserve a "C"?
0
 
LVL 1

Author Comment

by:Ege
ID: 6879304
Sorry ryancys,
I though "C" as a HALF POINT...

But it is not!

How can I change this? If not, post a comment to
"point and grade for ryancsys"
and get A :))
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6879795
I have corrected this for you and changed the "C" to an "A".  Thank you ryancys for your additional assistance to Ege here, I will also handle the other question for you.

Just to clarify the grading process, Ege, the points you assign are always the same, but the grade you give has a direct impact on the Expert points awarded.  Example, 100 point question with an A grade = 400 expert points, B grade = 300 and C grade = 200, so quite an impact, not to mention that few at this excellent site feel their assistance is anything less than excellent, and for the most part, I wholeheartedly agree.  

Moondancer - EE Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

947 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now