Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Name: tImmaY
hello. i'm trying to use the calculator "log" function in VB.NET and i'm having trouble with it. i have no clue why.. but i know that log(1000) != 7 b/c 10^7 != 1000. lol.. but this is the stripped code for just the beginning amount (fyi, i'm trying to calculate anual compound interest, we're doing it in my class but its the kind of program where the prof. gives you a sheet with instructions and you act like a drone and complete them in class. i'm too curious / impatient for that)
Dim P, temp1, LogOne As Integer 'P = principle, starting amount
P = Val(Starting_Amount_In.Text)
temp1 = Math.Log(P)
Messagebox.Show(P, "LogOne Result")
LogOne = 6 / temp1and then it goes on because the target amount is 1,000,000. i could do an if/then statement to check each value for t (time, the variable that we'd like to discover) until it gets to 1,000,000 but that would be a waste. i have LogOne = 6 / temp1 because log(1000000) = 6. so why is it telling me that the log of 1000 is 7?? lol

just an update, i've figured out you need to use the Math.Log10() function to get the log of a base10 number. however, i'm having problems with the rate.. it wont let me accept decimal points so for 2.50 it gives me the log of 2. but it will give me the log of 10, so how do i make it so that i can accept decimal points?

The syntax is ok with this statement but it is the source of your problem:
Dim P, temp1, LogOne As IntegerLogOne is given a data type of Integer. P and temp1 have no data types declared. Even though you do not have to give them a data type right away you have to be careful or the wrong type will be assumed later.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |