|
-
Jul 24th, 2007, 09:46 AM
#1
Thread Starter
PowerPoster
[RESOLVED] What is wrong with this statement?
My code:
Single PVal, TotPmts, Payment, Fmt, APR, APR2, PayType, FVal;
const int ENDPERIOD = 0;
const int BEGINPERIOD = 0;
--I will add code here later to get input data
If (APR > 1) then APR2 = APR / 100;
APR2 = APR2 / 12;
The "then" is underlined with the following message:
"; expected"
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Jul 24th, 2007, 09:53 AM
#2
Re: What is wrong with this statement?
There is no "Then" in an If statement like in VB.
Code:
if (APR > 1)
{
APR2 = APR / 100;
}
else
{
MessageBox.Show("APR is not greater than 1.");
}
-
Jul 24th, 2007, 09:54 AM
#3
Thread Starter
PowerPoster
Re: What is wrong with this statement?
I get the same error with this :
If (APR > 1)
APR2 = APR / 100;
APR2 = APR2 / 12;
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Jul 24th, 2007, 10:04 AM
#4
Thread Starter
PowerPoster
Re: What is wrong with this statement?
Got it. "If" is not the same as "if". C# will take some getting used to. :-)
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Jul 24th, 2007, 10:10 AM
#5
Re: What is wrong with this statement?
 Originally Posted by Pasvorto
Got it. "If" is not the same as "if". C# will take some getting used to. :-)
That's right.
Also note that this:
Code:
if (1 == 2)
MessageBox.Show("What? 1 equals 2? I bet you don't see this message box.");
MessageBox.Show("Hi there. You do see me.");
is not the same as this:
Code:
if (1 == 2)
{
MessageBox.Show("What? 1 equals 2? I bet you don't see this message box.");
MessageBox.Show("Now you don't see me either.");
}
If you do not include the brackets, the if statement is only checking the first line. Personally I always use them as it is just clearer to me.
APR2 = APR2 / 12; in your code is always going to execute.
-
Jul 24th, 2007, 10:16 AM
#6
Thread Starter
PowerPoster
Re: [RESOLVED] What is wrong with this statement?
I want the APR2 = APR2 / 12 to always execute.
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Jul 24th, 2007, 10:21 AM
#7
Re: [RESOLVED] What is wrong with this statement?
 Originally Posted by Pasvorto
I want the APR2 = APR2 / 12 to always execute.
Ok then. It will.
-
Jul 24th, 2007, 10:31 AM
#8
Thread Starter
PowerPoster
Re: [RESOLVED] What is wrong with this statement?
Another hurdle overcome...
===================================================
If your question has been answered, mark the thread as [RESOLVED]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|