Computing.Net > Forums > Programming > Math.Function in VB - Help!

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Math.Function in VB - Help!

Reply to Message Icon

Name: tImmaY
Date: November 14, 2004 at 23:03:32 Pacific
OS: Windows XP Pro SP1
CPU/Ram: AMD Athlon XP 2400+ / 512
Comment:

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 / temp1

and 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



Sponsored Link
Ads by Google

Response Number 1
Name: tImmaY
Date: November 15, 2004 at 00:16:50 Pacific
Reply:

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?


0

Response Number 2
Name: egkenny
Date: November 15, 2004 at 16:58:51 Pacific
Reply:

The syntax is ok with this statement but it is the source of your problem:
Dim P, temp1, LogOne As Integer

LogOne 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.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Math.Function in VB - Help!

Function in VB 6 www.computing.net/answers/programming/function-in-vb-6/9626.html

Functions in VB www.computing.net/answers/programming/functions-in-vb/9972.html

random function in VB www.computing.net/answers/programming/random-function-in-vb/12282.html