| | |
help with datetimepicker...
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2008
Posts: 23
Reputation:
Solved Threads: 0
can some help me with this datetimepicker problem...
btime1 is my datetimepicker(format is time)
the problem now is the first IF statement is not executing....i'm having trouble comparing them...can someone help me pls?
the allowed booking time is from 6pm to 10pm....somehow its not working..
thank u...
btime1 is my datetimepicker(format is time)
VB.NET Syntax (Toggle Plain Text)
Dim time559 As DateTime Dim time1001 As DateTime time559 = FormatDateTime("5:00:00 PM", DateFormat.LongTime) time1001 = FormatDateTime("10:01:00 PM", DateFormat.LongTime) If Btime1.Value < time559 And Btime1.Value > time1001 Then MsgBox("Booking Time is only available from 6.00 PM to 10.00 PM ") Rpanel1.Show() Else PListBox1.Items.Add("Customer Name" & ControlChars.Tab & _ ControlChars.Tab & "Booking Date" & ControlChars.Tab & _ ControlChars.Tab & "Booking Time") status1 = "Booked" Table1.BackColor = Color.Khaki PListBox1.Items.Add(Bcusname1.Text & ControlChars.Tab & _ ControlChars.Tab & ControlChars.Tab & Bdate1.Value & ControlChars.Tab & _ ControlChars.Tab & Btime1.Value)
the problem now is the first IF statement is not executing....i'm having trouble comparing them...can someone help me pls?
the allowed booking time is from 6pm to 10pm....somehow its not working..
thank u...
Last edited by gopi17; Oct 3rd, 2008 at 8:30 am.
There are two problems:
1) In the If statement, the And should be Or.
2) Even if you change the Format property of the DateTimePicker to Time, the datetimepicker still stores the date. Therefore, the If statement is comparing 5:00 PM and 10:01 PM to, in my case 10/3/2008 6:00 PM. Because of the date part of the datetimepicker, the value in the date timepicker will always be larger than 10:01 PM.
Here is some code I put together to overcome these two issues:
Let me know if that works.
1) In the If statement, the And should be Or.
2) Even if you change the Format property of the DateTimePicker to Time, the datetimepicker still stores the date. Therefore, the If statement is comparing 5:00 PM and 10:01 PM to, in my case 10/3/2008 6:00 PM. Because of the date part of the datetimepicker, the value in the date timepicker will always be larger than 10:01 PM.
Here is some code I put together to overcome these two issues:
vb Syntax (Toggle Plain Text)
Dim time559 As DateTime Dim time1001 As DateTime Dim time1 As DateTime time559 = FormatDateTime("5:00:00 PM", DateFormat.LongTime) time1001 = FormatDateTime("10:01:00 PM", DateFormat.LongTime) time1 = FormatDateTime(Hour(btime1.Value) & ":" & Minute(btime1.Value)) If time1 < time559 Or time1 > time1001 Then MsgBox("Booking Time is only available from 6.00 PM to 10.00 PM ") Else MsgBox("OK ") End If
Let me know if that works.
I don't know what comparisons you are trying to make, so here is some general code on how to get the selected date, today's date and tomorrow's date. You just need to create an If statement to make the comparisons you want.
vb Syntax (Toggle Plain Text)
Dim chosenDate As Date Dim dateToday As Date Dim dateTomorrow As Date chosenDate = FormatDateTime(DatePart(DateInterval.Month, btime1.Value) & "/" & DatePart(DateInterval.Day, btime1.Value) & "/" & DatePart(DateInterval.Year, btime1.Value), DateFormat.ShortDate) dateToday = FormatDateTime(Now, DateFormat.ShortDate) dateTomorrow = DateAdd(DateInterval.Day, 1, dateToday)
![]() |
Similar Threads
- How to add DateTimePicker to ToolStrip ? (C#)
- DateTimePicker counter (Visual Basic 4 / 5 / 6)
- How to link a data row to datetimepicker (VB.NET)
- How to save a date from a datetimepicker in Borland C++ builder? (C++)
- datetimepicker (VB.NET)
- C++ Builder 6 - DateTimePicker (C++)
Other Threads in the VB.NET Forum
- Previous Thread: Image in TITLE BAR?
- Next Thread: need help in filling combobox or listbox with dataset
| Thread Tools | Search this Thread |
.net .net2005 30minutes 2005 2008 access account arithmetic array basic binary bing button buttons center check code combobox component connectionstring crystalreport data database databasesearch datagrid datagridview date design dissertation dissertations dissertationthesis dropdownlist excel fade file-dialog folder ftp generatetags google gridview hardcopy image images input insert intel internet mobile monitor ms net networking objects output passingparameters peertopeervideostreaming picturebox picturebox1 port print problem problemwithinstallation project reports" save savedialog searchbox searchvb.net select serial shutdown soap survey table tcp temperature text textbox timer toolbox trim update updown user usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web winforms wpf





