Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 149,406 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 2,193 people online right now. Registration is fast and FREE... Join Now!




DTP Issue VB Exp. Edition 2005

 
Reply to this topicStart new topic

DTP Issue VB Exp. Edition 2005

gram999
21 Jan, 2008 - 09:42 AM
Post #1

D.I.C Head
**

Joined: 21 Jan, 2008
Posts: 81



Thanked: 2 times
My Contributions
I am using the DTP tool in VB Express Edition 2005. What I am trying to do is when a user selects a date in the past, for instance December 1, 2007, using the DTP the code will add 45 days to that date and if todays date is <= 12/1/2007 + 45 then it returns a certain form. If it is > 12/1/2007 + 45 then it returns a different form. I should add that I am trying to convert VB that currently does this in an old 2003 version Excel wookbook to a stand alone VB application. Any and all suggestions are welcomes and appreciated.

Old Excel VB Code that I wrote that worked:
CODE

Private Sub cmdbDBAOk_Click

Dim dtNowDate As Date
Dim dtDTP As Date
Dim dtDate45 As Date

dtNowDate = Now()         "Today's Date"
dtDTP = DTPDBA.Value   "This line is the value that the user selects from the DTP"
dtDate45 = dtDTP + 45    "This line adds the 45 days"

If dtNowDate . dtDate45 Then

Me.Hide
frmPastDBADate.Show
End If

If dtNowDate <= dtDate45 Then

Me. Hide
frmEligDBA.Show
End If

End Sub



Since the NOW() function is not available in VB Express this is the code that I have been trying unsuccessfully:

CODE

Public Class frmFileDBA

    Private Sub cmdbDBAOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdbDBAOk.Click

        Dim dtNowDate As Date
        Dim dtDTP As Date
        Dim dtDate45 As Date
        Dim intDays As Integer

        dtNowDate = Today
        dtDTP = dtpDBA.Value
        intDays = 45
        dtDate45 = dtDTP + intDays

        If dtNowDate > dtDate45 Then
            Me.Hide()
            frmPastDBADate.Show()
        End If

        If dtNowDate <= dtDate45 Then
            Me.Hide()
            frmEligDBA.Show()
        End If


    End Sub
End Class



The error that I am getting is "Operator '+' is not defined for types 'Date' and 'Integer' Thanks in advance for your assistance.
User is offlineProfile CardPM
+Quote Post

Jayman
RE: DTP Issue VB Exp. Edition 2005
21 Jan, 2008 - 11:07 AM
Post #2

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 7,297



Thanked: 66 times
Dream Kudos: 500
Expert In: Everything

My Contributions
Moved to the VB.NET forum.

You cannot use operators to manipulate dates. Use the AddDays method.
CODE

dtDate45 = dtDTP.AddDays(intDays)

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 10:30AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month