C
C.Davidson
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.
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.