469,632 Members | 1,732 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,632 developers. It's quick & easy.

VB.Net 2003 DateAdd Function

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
1 18792
"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.

Similar topics

reply views Thread by Zlatko Matić | last post: by
2 posts views Thread by Abdul N K | last post: by
4 posts views Thread by ey.markov | last post: by
reply views Thread by Zlatko Matić | last post: by
2 posts views Thread by Rich Raffenetti | last post: by
3 posts views Thread by Mel | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.