By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,573 Members | 1,797 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,573 IT Pros & Developers. It's quick & easy.

VB.Net 2003 DateAdd Function

P: n/a
Does subject VB.net 2003 support DateAdd function? I have tried to
implement the following without success. In my example I tried to
simply add 30 months to 9/18/2003 and I get "New date: 12:00:00 AM",
no date
Example direct from VB Language Reference:

Public Overloads Function DateAdd(ByVal Interval As DateInterval,_
ByVal Number As Double, ByVal DateValue As DateTime) As DateTime
End Function

Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
Dim Msg, Number, StartDate As String
Dim Months As Double
Dim SecondDate As Date
Dim IntervalType As DateInterval
IntervalType = DateInterval.Month
StartDate = InputBox("Enter a Date")
SecondDate = CDate(StartDate)
Number = InputBox("Enter number of months to add") 'Input
Number of Added Months
Months = Val(Number)
Msg = "New date " & DateAdd(IntervalType, Number, SecondDate)
MsgBox(Msg)

Any Comments or suggestions welcomed
Thanks.
A retired EE and very novice programmer.
Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"C.Davidson" <cw***@swbell.net> schrieb
Does subject VB.net 2003 support DateAdd function? I have tried
to implement the following without success. In my example I tried
to simply add 30 months to 9/18/2003 and I get "New date: 12:00:00
AM", no date
Example direct from VB Language Reference:

Public Overloads Function DateAdd(ByVal Interval As DateInterval,_
ByVal Number As Double, ByVal DateValue As DateTime) As DateTime
End Function

Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
Dim Msg, Number, StartDate As String
Dim Months As Double
Dim SecondDate As Date
Dim IntervalType As DateInterval
IntervalType = DateInterval.Month
StartDate = InputBox("Enter a Date")
SecondDate = CDate(StartDate)
Number = InputBox("Enter number of months to add") 'Input
Number of Added Months
Months = Val(Number)
Msg = "New date " & DateAdd(IntervalType, Number,
SecondDate) MsgBox(Msg)

Any Comments or suggestions welcomed
Thanks.
A retired EE and very novice programmer.


Your function 'DateAdd' does nothing. I'd use the already existing DateAdd
function.
--
Armin

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.