Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Newbie Question


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-30-2008, 07:22 PM
Newbie
 
Join Date: May 2008
Posts: 5
Default Newbie Question

Hi, this is my first post on this great site. I have started playing around with the desktop version and am trying to make a loan formula, but I must be getting the syntax wrong.

Here is what it's supposed to look like:

Payment = (Rate + (Rate / ((1 + Rate) ^ Months) * -1)) * Principal

For some reason when I enter it like that I get a syntax error. I believe that my use of negative one is the problem.

I appreciate any help.
Thanks!
Steve
Reply With Quote
  #2 (permalink)  
Old 05-30-2008, 07:26 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,802
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Heve you tried to do the math step by step so that you can pinpoint the trouble bit?
__________________
Paulo Gomes
Porto, Portugal

"The Past is nothing more than the constructions of a Present that was once called Future"

Desktop PC: Currently NONE
Mobile Device: QTEK S200, WinMo 6.5
Laptop: Toshiba NB100-130

DLL Version Listing
Reply With Quote
  #3 (permalink)  
Old 05-30-2008, 07:33 PM
Newbie
 
Join Date: May 2008
Posts: 5
Default

Yes, and that's why I think the Negative one part is the problem.

This is just a calculation for a standard car loan.

Thanks for helping.
Reply With Quote
  #4 (permalink)  
Old 05-30-2008, 07:36 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,802
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

have you trried to wrap the negative one in parentesis as (-1)?
__________________
Paulo Gomes
Porto, Portugal

"The Past is nothing more than the constructions of a Present that was once called Future"

Desktop PC: Currently NONE
Mobile Device: QTEK S200, WinMo 6.5
Laptop: Toshiba NB100-130

DLL Version Listing
Reply With Quote
  #5 (permalink)  
Old 05-30-2008, 07:56 PM
Newbie
 
Join Date: May 2008
Posts: 5
Default

How do I step through? I press Debug, then step through, then I tried pressing F8 but it wouldn't work.
Reply With Quote
  #6 (permalink)  
Old 05-30-2008, 08:05 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,802
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Trip the formula and use msgboxs to show the current result...
Some thing like this:
Code:
Payment=(1 + RATE)* (-1) 'This should be the critic part, if you can pass this then all ok...
MSGBOX(payment)
Payment=(Payment+Rate) 'I don't know how you are implemeting the rate...But you should not introduce a percentage in a direct calculation...
MSGBOX(payment)

Payment = Payment * Principal
If I recal correctly, from my math lessons, multiplying by a negative number is equal to dividing by that absolut number(?)
Rate SHOULD not be in percentage, but represent the ratio...
__________________
Paulo Gomes
Porto, Portugal

"The Past is nothing more than the constructions of a Present that was once called Future"

Desktop PC: Currently NONE
Mobile Device: QTEK S200, WinMo 6.5
Laptop: Toshiba NB100-130

DLL Version Listing
Reply With Quote
  #7 (permalink)  
Old 05-30-2008, 08:27 PM
Newbie
 
Join Date: May 2008
Posts: 5
Default

I figured it out. I made an error. I was supposed to subtract 1, not multiply by negative one. Here's my final code:

Sub cmdCalc_Click
Dim Prin
Dim Rate
Dim Term
Dim MonthlyRate
Dim Payment
Dim Middle
Dim bottom



Prin = txtPrin.Text
Rate = txtRate.Text / 1200
Term = txtLength.Text * 12

bottom = ((1 + Rate) ^ (Term ))
bottom = bottom - 1
middle = Rate / bottom
Payment = (Rate + middle) * Prin

lblOut.Text = Payment

Thanks for the help.
Reply With Quote
  #8 (permalink)  
Old 05-30-2008, 08:32 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,802
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Quote:
Originally Posted by Stevenator65 View Post
I figured it out. I made an error. I was supposed to subtract 1, not multiply by negative one. Here's my final code:

Sub cmdCalc_Click
Dim Prin
Dim Rate
Dim Term
Dim MonthlyRate
Dim Payment
Dim Middle
Dim bottom
There's no need to "Dim" normal variables....
You can just use the without previous settings...
If you need to share a variable bettween several subs, then put them in the Global sub, like this:

Prin=""
Rate=""
Term=""
MonthlyRate=""
Payment=""
Middle=""
bottom=""
__________________
Paulo Gomes
Porto, Portugal

"The Past is nothing more than the constructions of a Present that was once called Future"

Desktop PC: Currently NONE
Mobile Device: QTEK S200, WinMo 6.5
Laptop: Toshiba NB100-130

DLL Version Listing
Reply With Quote
  #9 (permalink)  
Old 05-30-2008, 08:46 PM
Newbie
 
Join Date: May 2008
Posts: 5
Default

Thanks again Cableguy. I'm starting to like this software, and the forum is top notch.
Reply With Quote
  #10 (permalink)  
Old 05-30-2008, 08:53 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,802
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Quote:
Originally Posted by Stevenator65 View Post
Thanks again Cableguy. I'm starting to like this software, and the forum is top notch.
Glad to ear that, and always glad to help...
__________________
Paulo Gomes
Porto, Portugal

"The Past is nothing more than the constructions of a Present that was once called Future"

Desktop PC: Currently NONE
Mobile Device: QTEK S200, WinMo 6.5
Laptop: Toshiba NB100-130

DLL Version Listing
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
SQLite newbie question JamesC Chit Chat 1 08-01-2008 08:26 AM
SQLite external library newbie question JamesC Questions & Help Needed 2 05-29-2008 03:48 AM
Newbie question - arrays and tables BjornF Questions & Help Needed 3 05-15-2008 09:29 AM
Another newbie question: How to refere to the active form? yildi Questions & Help Needed 2 11-17-2007 07:55 PM
Newbie - question about loadXML yildi Questions & Help Needed 6 11-12-2007 11:43 PM


All times are GMT. The time now is 12:02 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0