Solved

How to compare DataSet value to a Date enter.

Posted on 2011-02-10
2
371 Views
Last Modified: 2012-05-11
How do I compare Date enterd to a DataSet in the code below:
'Warn user if the Posted entered is a future date.
        If UtilityClass.UnmaskDate(Me.fPostedDate.Text) = Nothing Then
            'nothing to check, bail out
            Exit Sub
        End If
'Error Here
        Select Case (UtilityClass.UnmaskDate(Me.fPostedDate.Text) = Format(PaymentsDataSet.Tables(0).Rows(I).Item("PostedDate"), "MM/dd/yy"))
            Case False
                Exit Sub
            Case True
                Select Case LastNewFinRecord
                    Case 0
                        ' there is not a new finance record id yet. leave it alone
                    Case CInt(Me.fFinRecID.Text)
                        If UtilityClass.UnmaskDate(Me.fPostedDate.Text) = Nothing Then
                            'nothing to check, bail out
                            Exit Sub
                        Else
                            ' Is the Posted Date greater than Today.
                            If (DateTime.Parse(UtilityClass.UnmaskDate(Me.fPostedDate.Text))) > DateTime.Parse(UtilityClass.UnmaskDate(Today)) Then
                                Select Case MessageBox.Show("This Date is in the FUTURE" & vbCrLf & "Is that correct.", "Incorrect Posted Date", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation)
                                    Case vbYes
                                        Me.fPostMarkDate.Focus()
                                    Case vbNo
                                        Me.fPostedDate.Focus()
                                End Select
                            End If
                        End If
                    Case Else
                End Select
        End Select

Open in new window

I get Arguement expression is not valid value.
0
Comment
Question by:pelon_80
2 Comments
 
LVL 9

Accepted Solution

by:
skipper68 earned 500 total points
ID: 34867454
It appears that there may be some values that are "null" (empty). What would you like to do with them?  To confirm, you can display a message box before the line it's failing on to determine this.

If there are nulls in the data, then you should check to see if it is = DBNull.Value before you try to use it in any function or before casting them ( CInt () ).

if Me.xx.Text <> DBNull.Value Then
     'Do Something
else
     'Do Something Else
End If

0
 

Author Closing Comment

by:pelon_80
ID: 34871682
Great! Thanks
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now