|
-
Mar 6th, 2010, 07:53 AM
#1
Thread Starter
Addicted Member
Spliting
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!
-
Mar 6th, 2010, 08:09 AM
#2
Re: Spliting
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
-
Mar 6th, 2010, 08:09 AM
#3
Re: Spliting
I just typed this in Notepad. Please amend syntax error if any...
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
Hope I have understood your query correctly...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Mar 6th, 2010, 08:12 AM
#4
Re: Spliting
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
-
Mar 6th, 2010, 08:14 AM
#5
Lively Member
Re: Spliting
use Some thing like first it would split the months in 12.3.2010 and 17.3.2010
use
Code:
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")
Do something like this
-
Mar 6th, 2010, 08:17 AM
#6
Re: Spliting
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
-
Mar 6th, 2010, 08:32 AM
#7
Thread Starter
Addicted Member
Re: Spliting
@watson123, your code doesn't work.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|