This is a multi-part message in MIME format.

------=_NextPart_000_0008_01C357A7.083398E0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

All,

I am trying to calculate an if statement base of a value of 12 =
multiplier. I'd much rather not have to type this all the way up for 60 =
years. How can I turn my if statement into something like If Period =
=3D 12 or multiplier of 12 then?


For Period =3D 1 To TotPmts
'My period Work
If Period =3D 12 Or Period =3D 24 Or Period =3D 36 Or Period =
=3D 48 Or Period =3D 60 _
Or Period =3D 72 Or Period =3D ...........Then

End If

Next Period


Thanks,
Brian P. Hammer
------=_NextPart_000_0008_01C357A7.083398E0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1170" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV>All,</DIV>
<DIV>&nbsp;</DIV>
<DIV>I am trying to calculate an if statement base of a value of&nbsp; =
12=20
multiplier.&nbsp; I'd much rather not have to type this all the way up =
for 60=20
years.&nbsp; How can I turn my if statement into something like&nbsp; If =
Period=20
=3D 12 or multiplier of 12 then?</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For Period =3D 1 To=20
TotPmts<BR>'My&nbsp; period Work</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
If=20
Period =3D 12 Or Period =3D 24 Or Period =3D 36 Or Period =3D 48 Or =
Period =3D 60=20
_<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
Or=20
Period =3D 72 Or Period =3D&nbsp;...........Then<BR></DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
End=20
If<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next =
Period<BR></DIV>
<DIV><BR>Thanks,<BR>Brian P. Hammer</DIV></BODY></HTML>

------=_NextPart_000_0008_01C357A7.083398E0--

Re: An If Then but Different by Stephen

Stephen
Thu Jul 31 22:06:17 CDT 2003

Brian,

On solution would be to use the Mod operator

If Period Mod 12 = 0 Then
'Its a multiple of 12
End If

Stephen

"Brian P. Hammer" <bphammer@SpamMeNotCAAP.com> wrote in message
news:uNpryD9VDHA.612@TK2MSFTNGP10.phx.gbl...
All,

I am trying to calculate an if statement base of a value of 12 multiplier.
I'd much rather not have to type this all the way up for 60 years. How can
I turn my if statement into something like If Period = 12 or multiplier of
12 then?


For Period = 1 To TotPmts
'My period Work
If Period = 12 Or Period = 24 Or Period = 36 Or Period = 48 Or
Period = 60 _
Or Period = 72 Or Period = ...........Then

End If

Next Period


Thanks,
Brian P. Hammer



Re: An If Then but Different by Brian

Brian
Fri Aug 01 09:31:26 CDT 2003

You know, I didn't even think about that. I'll give it a try. I am sure it
will work because it's so simple. :-)


--
Brian P. Hammer
"Stephen Muecke" <stevejo@senet.com.au> wrote in message
news:uRogjn9VDHA.1744@TK2MSFTNGP12.phx.gbl...
> Brian,
>
> On solution would be to use the Mod operator
>
> If Period Mod 12 = 0 Then
> 'Its a multiple of 12
> End If
>
> Stephen
>
> "Brian P. Hammer" <bphammer@SpamMeNotCAAP.com> wrote in message
> news:uNpryD9VDHA.612@TK2MSFTNGP10.phx.gbl...
> All,
>
> I am trying to calculate an if statement base of a value of 12
multiplier.
> I'd much rather not have to type this all the way up for 60 years. How
can
> I turn my if statement into something like If Period = 12 or multiplier
of
> 12 then?
>
>
> For Period = 1 To TotPmts
> 'My period Work
> If Period = 12 Or Period = 24 Or Period = 36 Or Period = 48 Or
> Period = 60 _
> Or Period = 72 Or Period = ...........Then
>
> End If
>
> Next Period
>
>
> Thanks,
> Brian P. Hammer
>
>



Re: An If Then but Different by Jay

Jay
Fri Aug 01 10:33:25 CDT 2003

Brian,
If the Mod operator does apply. (It should in this case, I'm saying in other
cases).

- You can use a Select Case.

Select Case period
Case 12, 24, 36, 48, 60
' good period
Case Else
End Select

- Create a function that does the check.

If IsAnnual(period) Then
' good period
End If

Function IsAnnual(period as integer) As Boolean
Return period mod 12
End Function

- Store the values in an array, and check the array for the value.

Dim periods() As Integer = {12, 24, 36, 48, 60}
If Array.IndexOf(periods, period) >= 0 Then
' good period
End If

' If periods is sorted, binary search is faster!
If Array.BinarySearch(periods, period) >= 0 Then
' good period
End If

Of course with multiples of 12, Mod is easier. Even with the Mod operator I
would consider a function, as the function name indicates what you are
checking, were as Mod just says you are doing a Mod. Of course you could put
a comment before the Mod, However the function name would be my comment...
Actually depending on how I was using period throughout my app I would
consider making it a Type itself, then my check would be "If period.IsAnnual
Then" as the Period Type would encapsulate all the functionality unique to
Periods... By Type I mean a Structure or Class depending on how I was using
the Period Type.

Hope this helps
Jay


"Brian P. Hammer" <bphammer@SpamMeNotCAAP.com> wrote in message
news:uNpryD9VDHA.612@TK2MSFTNGP10.phx.gbl...
All,

I am trying to calculate an if statement base of a value of 12 multiplier.
I'd much rather not have to type this all the way up for 60 years. How can
I turn my if statement into something like If Period = 12 or multiplier of
12 then?


For Period = 1 To TotPmts
'My period Work
If Period = 12 Or Period = 24 Or Period = 36 Or Period = 48 Or
Period = 60 _
Or Period = 72 Or Period = ...........Then

End If

Next Period


Thanks,
Brian P. Hammer



Re: An If Then but Different by Brian

Brian
Fri Aug 01 21:54:28 CDT 2003

Wow Jay, thanks for the pointers. I had thought about a case select but
after about 132, I have to break out the calculator. :)

Using a type in this case is beyond what I need. I merely made a function
for my some loan numbers and return the principle and interest in the
function and then give the user a chance to view the amortization schedule.
I needed the Mod to separate the years, then I total each column in my array
and display it all in a rich text.

Thanks,

--
Brian P. Hammer
"Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@email.msn.com> wrote in message
news:OmkPDJEWDHA.2260@TK2MSFTNGP09.phx.gbl...
> Brian,
> If the Mod operator does apply. (It should in this case, I'm saying in
other
> cases).
>
> - You can use a Select Case.
>
> Select Case period
> Case 12, 24, 36, 48, 60
> ' good period
> Case Else
> End Select
>
> - Create a function that does the check.
>
> If IsAnnual(period) Then
> ' good period
> End If
>
> Function IsAnnual(period as integer) As Boolean
> Return period mod 12
> End Function
>
> - Store the values in an array, and check the array for the value.
>
> Dim periods() As Integer = {12, 24, 36, 48, 60}
> If Array.IndexOf(periods, period) >= 0 Then
> ' good period
> End If
>
> ' If periods is sorted, binary search is faster!
> If Array.BinarySearch(periods, period) >= 0 Then
> ' good period
> End If
>
> Of course with multiples of 12, Mod is easier. Even with the Mod operator
I
> would consider a function, as the function name indicates what you are
> checking, were as Mod just says you are doing a Mod. Of course you could
put
> a comment before the Mod, However the function name would be my comment...
> Actually depending on how I was using period throughout my app I would
> consider making it a Type itself, then my check would be "If
period.IsAnnual
> Then" as the Period Type would encapsulate all the functionality unique to
> Periods... By Type I mean a Structure or Class depending on how I was
using
> the Period Type.
>
> Hope this helps
> Jay
>
>
> "Brian P. Hammer" <bphammer@SpamMeNotCAAP.com> wrote in message
> news:uNpryD9VDHA.612@TK2MSFTNGP10.phx.gbl...
> All,
>
> I am trying to calculate an if statement base of a value of 12
multiplier.
> I'd much rather not have to type this all the way up for 60 years. How
can
> I turn my if statement into something like If Period = 12 or multiplier
of
> 12 then?
>
>
> For Period = 1 To TotPmts
> 'My period Work
> If Period = 12 Or Period = 24 Or Period = 36 Or Period = 48 Or
> Period = 60 _
> Or Period = 72 Or Period = ...........Then
>
> End If
>
> Next Period
>
>
> Thanks,
> Brian P. Hammer
>
>



Re: An If Then but Different by Chris

Chris
Wed Aug 06 12:12:12 CDT 2003

> Function IsAnnual(period as integer) As Boolean
> Return period mod 12
> End Function
>

Will this work with Option Strict On? In any event, I think it is better
like this:

Function InAnnual(period As Integer) As Boolean
Return (period mod 12) = 0
End Function

Your original function returned an integer (?) when a boolean was expected.
I realize that the compiler my be able to do an implicit conversion, but my
opinion is that conversions between integer and boolean should not be
allowed.

Just my 2 cents (probably worth less due to inflation and the economy!)

Chris

Re: An If Then but Different by Jay

Jay
Wed Aug 06 16:27:37 CDT 2003

Chris,
Remember, the intent of the sample was a quick sample of encapsulating the
formula in a function. It was not an example of the correct syntax to use
when writing said function.

You are correct it will fail with Option Strict on!

Thanks
Jay

"Chris Dunaway" <dunawayc@_lunchmeat_sbcglobal.net> wrote in message
news:Xns93CF7C23B90B3CAD@207.46.248.16...
> > Function IsAnnual(period as integer) As Boolean
> > Return period mod 12
> > End Function
> >
>
> Will this work with Option Strict On? In any event, I think it is better
> like this:
>
> Function InAnnual(period As Integer) As Boolean
> Return (period mod 12) = 0
> End Function
>
> Your original function returned an integer (?) when a boolean was
expected.
> I realize that the compiler my be able to do an implicit conversion, but
my
> opinion is that conversions between integer and boolean should not be
> allowed.
>
> Just my 2 cents (probably worth less due to inflation and the economy!)
>
> Chris