Expanding a bit on the solution:
DateInterval is an enum, what you need to do is create a variable of the
enum's type and pass the enum's value into the function's parameter.
Here's your example modified to use the enum's type.
Private Function calc_couponPeriod(ByVal Interval As DateInterval,
ByVal installmentBeginDate As Date, ByVal installmentPeriod As Integer) As
Date
Return installmentFutureDate = DateAdd(Interval, installment,
installmentBeginDate)
End Function
Private Sub btnRates_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnRates.Click
' Leave the installmentBeginDate as a date type - don't use the text
property
Dim installmentBeginDate = tbsettlementdate
Dim Interval As DateInterval =
Microsoft.VisualBasic.DateInterval.Year
Dim principal = "1000"
Dim accruedInterest = 0
'Changed to reflect adding an interval to the date - update it as
appropriate.
accruedInterestToDate = calc_couponPeriod(Interval,
installmentBeginDate, InstallmentPeriod)
End Sub
Check out the strong typing to get more info.
--------------------
From: hi***************@gmx.at (Herfried K. Wagner [MVP])
Newsgroups: microsoft.public.dotnet.languages.vb
Subject: Re: Passing Date Functions as variables
Date: 24 Nov 2003 20:44:54 +0100
Lines: 17
Sender: Administrator@FAMILIE-IF1R60H
Message-ID: <bp*************@ID-208219.news.uni-berlin.de>
References: <e9*************@TK2MSFTNGP11.phx.gbl>
NNTP-Posting-Host: v208-105.vps.tuwien.ac.at (128.131.208.105)
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: news.uni-berlin.de 1069703187 62565350 128.131.208.105 (16
[208219])X-Face:
vJn^g[Lkg9YfJ,Oj#{Y[')WBo<1kS#Rc3Vb!D;jf$;OZ%<"'z+DX"K/m)h\Gi;e-AYsc%'CmL~Ix
@YEq$}A>^]KbF1.Z|=/'*CcB[f+8(m&vP.u4+P.q$n]?[s>nnFu/8EuC?h[c\#wR{ok_um~57to=
P=1"{qO1e%A2~nS?<[o`jn?C/-}7Mbz~L)WI=5VL!*xU#^dUser-Agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Common Lisp (Windows))
Hamster/2.0.0.1Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTN GXA05.phx.gbl!TK2MSFTNGP08
.phx.gbl!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!f
u-berlin.de!uni-berlin.de!v208-105.vps.tuwien.ac.AT!not-for-mailXref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.languages.vb:158753
X-Tomcat-NG: microsoft.public.dotnet.languages.vb
* "IntraRELY" <In*******@yahoo.com> scripsit: I have the following function, Notice how I am passing the dateInterval
as a string. What is the correct way to pass "DateInterval.Year" as a
variable to a function?
What do you mean by "pass as a variable"? You can declare the first
parameter as 'DateInterval':
\\\
... CalcCouponPeriod(ByVal di As DateInterval, ....)
///
Then you can pass 'DateInterval.Year' directly.
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>