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_couponPeri od(ByVal Interval As DateInterval,
ByVal installmentBegi nDate As Date, ByVal installmentPeri od As Integer) As
Date
Return installmentFutu reDate = DateAdd(Interva l, installment,
installmentBegi nDate)
End Function
Private Sub btnRates_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnRates.Click
' Leave the installmentBegi nDate as a date type - don't use the text
property
Dim installmentBegi nDate = tbsettlementdat e
Dim Interval As DateInterval =
Microsoft.Visua lBasic.DateInte rval.Year
Dim principal = "1000"
Dim accruedInterest = 0
'Changed to reflect adding an interval to the date - update it as
appropriate.
accruedInterest ToDate = calc_couponPeri od(Interval,
installmentBegi nDate, InstallmentPeri od)
End Sub
Check out the strong typing to get more info.
--------------------
From: hi************* **@gmx.at (Herfried K. Wagner [MVP])
Newsgroups: microsoft.publi c.dotnet.langua ges.vb
Subject: Re: Passing Date Functions as variables
Date: 24 Nov 2003 20:44:54 +0100
Lines: 17
Sender: Administrator@F AMILIE-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.10 5)
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~57t o=
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.ph x.gbl!cpmsftngx a10.phx.gbl!TK2 MSFTNGXA05.phx. gbl!TK2MSFTNGP0 8
.phx.gbl!newsfe ed00.sul.t-online.de!newsf eed01.sul.t-online.de!t-online.de!f
u-berlin.de!uni-berlin.de!v208-105.vps.tuwien. ac.AT!not-for-mailXref: cpmsftngxa07.ph x.gbl microsoft.publi c.dotnet.langua ges.vb:158753
X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.vb
* "IntraRELY" <In*******@yaho o.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.Y ear" as a
variable to a function?
What do you mean by "pass as a variable"? You can declare the first
parameter as 'DateInterval':
\\\
... CalcCouponPerio d(ByVal di As DateInterval, ....)
///
Then you can pass 'DateInterval.Y ear' directly.
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>