473,785 Members | 2,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing Date Functions as variables

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?

TIA,

Steve Wofford
www.IntraRELY.com
Private Function calc_couponPeri od(ByVal DateInterval As Integer, ByVal
installmentBegi nDate As Date, ByVal installment As Date)
Return installmentFutu reDate = DateAdd(dateInt erval, installment,
installmentBegi nDate)
End Function

Private Sub btnRates_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnRates.Click
Dim installmentBegi nDate = tbSettlementDat e.Text
Dim dateInterval = "DateInterval.Y ear"
Dim principal = "1000"
Dim accruedInterest = 0
accruedInterest ToDate = calc_couponPeri od(DateInterval ,
installmentBegi nDate, principal, accruedInterest ToDate)
End Sub
Nov 20 '05 #1
3 1922
* "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>
Nov 20 '05 #2
"IntraRELY" <In*******@yaho o.com> wrote...
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? Private Function calc_couponPeri od(ByVal DateInterval As Integer, ByVal
installmentBegi nDate As Date, ByVal installment As Date)
Return installmentFutu reDate = DateAdd(dateInt erval, installment,
installmentBegi nDate)
End Function

Private Sub btnRates_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnRates.Click
Dim installmentBegi nDate = tbSettlementDat e.Text
Dim dateInterval = "DateInterval.Y ear"
Dim principal = "1000"
Dim accruedInterest = 0
accruedInterest ToDate = calc_couponPeri od(DateInterval ,
installmentBegi nDate, principal, accruedInterest ToDate)
End Sub


Steve... something is up. Turn "Strict On" in your project options. Look
at your Dim statements you haven't declared their type. That's not good.
Plus you're assigning principal as a string, that can't be right. And your
function wants 3 parameters and you're passing 4... and... I guess I had
better stop there.

Your function is expecting the DateInterval parameter to be an Integer, you
can see that, but then why would you set it to be a string?

It also looks like you've defined accruedInterest (no type) assigned it a
value of zero and did nothing with it. Time to slow down, take a breath and
think the entire process through.

Tom
Nov 20 '05 #3
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>


Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1915
by: Chieko Kuroda | last post by:
Hello all, I would like to learn the syntax for passing variables that I retreived from a database to a second asp page. Currently, I'm using: Response.Write "<tr><td>&nbsp;</td><td><Font size= ""-1""><B><a href= ""InterviewerInfo2.asp?timeID=" & rs("Starttime") & " "">" How do I add more variables to my link: <a href = ...? ie Nameofcandidate and InterviewDate in this context:
3
14952
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) { document.images.src = eval("mt" +menu+ ".src") } alert("imgOff_hidemenu"); hideMenu=setTimeout('Hide(menu,num)',500);
58
10181
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of code... TCHAR myArray; DoStuff(myArray);
9
2171
by: Max | last post by:
I'm new with Javascript and can't seem to figure out what I'm doing wrong here as I'm not able to pass a simple variable to a function. In the head of doc I have: <script type="text/javascript"> function radioenable(value) { document.forms.search.elements.value.disabled=false;
6
3259
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A query-string flag is used to indicate to the page whether it should instantiate a new instance of the object or access an existing instance from the calling page. On the both pages I have a property of the page which is an instance of this custom...
2
2298
by: Keith | last post by:
Good Afternoon, New to .Net. I am trying to pass date/time values to a MS Access query depending on what value is selected from a dropdown list box (January, February, etc). I have declared those values as date datatypes and assigned their values with the # signs in front and back. When I click the submit I get the following error message: Data type mismatch in criteria expression cmdSelect1 = New OleDbCommand("Select Count(*) from ...
1
2827
by: Roy | last post by:
I'm assuming this is amazingly simple and I'm just missing the boat. On the html side of an asp.net page I have a datagrid, a "search" button, and 8 text boxes for search criteria. A user enters in varying search criteria, hits "search", info is passed to a stored proc, results return and displayed in the datagrid. Every field in the datagrid is numeric (indicative of a certain sum or total) data but also functions as a...
12
6905
by: Dennis D. | last post by:
Hello: I want a function to return three variables to the calling procedure: Private Function CalcTimes(ByVal iAddDays as Integer, ByVal iAddHours as Integer, ByVal iAddMins as Integer) As Array Variable values are calculated in the function. Calling procedure receives the values preferably into variables of the same
1
1889
by: Lauren Quantrell | last post by:
I already figured out (the hard way) I need to convert all my date parameters into USA format before executing my stored procedures where dates are used as parameters. (Format(StartDate, "m/d/yyyy hh:nn:ss AM/PM") At least I thought I did! But then I discover that if I use the following construction, the dates do not need to be formatted to USA first:
0
10325
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10091
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.