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

Math.Function in VB - Help!

Reply to Message Icon

Original Message
Name: tImmaY
Date: November 14, 2004 at 23:03:32 Pacific
Subject: Math.Function in VB - Help!
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


Report Offensive Message For Removal


Response Number 1
Name: tImmaY
Date: November 15, 2004 at 00:16:50 Pacific
Subject: Math.Function in VB - Help!
Reply: (edit)

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?


Report Offensive Follow Up For Removal

Response Number 2
Name: egkenny
Date: November 15, 2004 at 16:58:51 Pacific
Subject: Math.Function in VB - Help!
Reply: (edit)

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.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Math.Function in VB - Help!

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 2 Days.
Discuss in The Lounge