Hello!
I have two days, for example:
12.3.2010
and
17.3.2010
And, how to check is some date, for example 15.3.2010 member of all dates between 12.3.2010 and 17.3.2010?
If it is, msgbox OK, if it isn't, msgbox NO.
Thanks!
Printable View
Hello!
I have two days, for example:
12.3.2010
and
17.3.2010
And, how to check is some date, for example 15.3.2010 member of all dates between 12.3.2010 and 17.3.2010?
If it is, msgbox OK, if it isn't, msgbox NO.
Thanks!
Hi,
A way how to detect the today:
vb Code:
If Date.Today = "25 / 12 " Then MsgBox("It's Christmas") Else MsgBox("It's not christmas") End If
I just typed this in Notepad. Please amend syntax error if any...
Hope I have understood your query correctly...Code:Dim dtStart As Date, dtEnd As Date, dtCheck As Date
Dim DateStart As String = "12.3.2010"
dtStart = Date.Parse(DateStart.Replace(".", "/")).ToShortDateString
Dim DateEnd As String = "17.3.2010"
dtEnd = Date.Parse(DateEnd.Replace(".", "/")).ToShortDateString
Dim DateCheck As String = "15.3.2010"
dtCheck = Date.Parse(DateCheck.Replace(".", "/")).ToShortDateString
If dtCheck > dtStart And dtCheck < dtEnd Then
'~~> your code here in case it falls between the dates
Else
'~~> your code here in case it doesn't fall between the dates
End If
Hey,
Only one suggestion to make to Koolsid's suggestion, and that would be to use .TryParse rather than .Parse.
That way, you can verify whether the code was correctly able to determine a valid DateTime from the object, before continuing.
Gary
use Some thing like first it would split the months in 12.3.2010 and 17.3.2010
use
Do something like thisCode:Dim firstdate as String = textbox1.Text ' Use It somewhere your date is there
Dim seconddate as String = Textbox2.Text ' use it somewher your second date is there
Dim Stext() AS String = SPlit(firstdate , ".")
DIm Secondtext() AS String = SPlit(seconddate , ".")
If stext(1) = secondtext(1) Then ' this would check if your months are same make 'something for year as well
If stext(0) > secondtext(0) then
MsgBox("YES")
END If
End if
Else
MsgBox("NO")
Or, if you are taking input from the user, don't let them type the date in at all. Use a DateTimePicker, or a MaskedTextBox instead.
Gary
@watson123, your code doesn't work. :(