Please Help, the user can only input today's date and tomorrow's date... How can i get it??
example valid dates are: Today's date: March 01, 2011 and tomorrow's date: March 02, 2011
if the dates are not valid then error.... Thank You...

Dim DD As String : Dim MM As String : Dim YYYY As String 
            Dim DDMMYYY As String
            DD = Now.Day : MM = Now.Month : YYYY = Now.Year
            If DD.Length = 1 Then DD = 0 & DD
            If MM.Length = 1 Then MM = 0 & MM

            DDMMYYY = MM & "/" & DD & "/" & YYYY
            MskTxtBoxDate.Text = DDMMYYY

See if this helps to check and compare the Date value in a MaskedTextBox.
1 MaskedTextBox

Public Class Form1
   
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        MaskedTextBox1.Mask = "00/00/0000" '// set Mask for Date Format.
        MaskedTextBox1.Text = "3 / 2/11" '// for testing.
    End Sub

    Private Sub MaskedTextBox1_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MaskedTextBox1.Validated
        Dim dtToday As Date = CDate(Date.Now.ToShortDateString) '// get Today's Date as "month/day/year"
        Dim dtTomorrow As Date = CDate(Date.Now.AddDays(1).ToShortDateString) '// get Tomorrow's Date as "month/day/year"
        Dim dtUserInput As Date '// for getting the MaskedTextBox.Text formated as Date.
        With MaskedTextBox1.Text.Split("/"c) '// .Split MaskedTextBox.Text into 3 arrays. (0)=month, (1)=day, (2)=year.
            '// check if all 3 arrays have values.
            If Not .GetValue(0) Is Nothing AndAlso Not .GetValue(1) Is Nothing AndAlso Not .GetValue(2) Is Nothing Then
                '// get MaskedTextBox.Text converted to Date.
                dtUserInput = CDate(CInt(.GetValue(0)) & "/" & CInt(.GetValue(1)) & "/" & CInt(.GetValue(2)))
                If dtUserInput = dtToday OrElse dtUserInput = dtTomorrow Then '// check if  MaskedTextBox is Today or Tomorrow.
                    MsgBox("Correct date, proceed with code.")
                    MaskedTextBox1.Text = Format(CDate(MaskedTextBox1.Text), "MM/dd/yyy") '// format Date to ##/##/#### if needed.
                Else '// if NOT MaskedTextBox is Today or Tomorrow.
                    MsgBox("Not Today or Tomorrow." & vbNewLine & "Try again.", MsgBoxStyle.Information)
                    MaskedTextBox1.Select()
                End If
            Else '// if a value has not been added to either month/day/year in MaskedTextBox.Text.
                MsgBox("Enter a complete date.", MsgBoxStyle.Critical)
                MaskedTextBox1.Select()
            End If
        End With
    End Sub
End Class
commented: great!!! +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.