What are you trying to evaluate for? Either condition or both?
Printable View
What are you trying to evaluate for? Either condition or both?
It's Either condition that i need.
Even if i change it to...
There's an error saying that " Conversion from string "008: 00" to type 'Date' is not valid."Code:If MyItems.Item(i).Start >= CType(Date.Today.TimeOfDay.Hours & "08: 00", DateTime) Then
TextBox5.Text = 1
Else
TextBox5.Text = 0
Date.Today.TimeOfDay.Hours & CType("08: 00", DateTime)
Will work.
Oh it can work for 8AM...but when i change to 10AM then it will give error.
Error is ...
Conversion from string "010:00:00 AM" to type 'Date' is not valid.
Why does it have a preceeding zero for 10?
010:00:00 AM
No idea...
this is the code i use...
vb Code:
If MyItems.Item(i).Start >= Date.Today.TimeOfDay.Hours & CType("10:00", DateTime) Then TextBox6.Text = 2 Else TextBox6.Text = 0 End if
Something wrong with it?
Whats the value of this...
Date.Today.TimeOfDay.Hours
Probably the cause of the preceeding zero.
Hmm..ok...i remove it and it works but then i having problems is that i created 8 textbox.
1st textbox is for timing within 8am to 10am
so if i have an appointment start at 8 30 till 9 30 then the 1st textbox will be = 1
2nd textbox is for timing within 10am to 12am
so .... and so on...
like #74
problem is that how do i make that way?
i tried using it and all textbox display it out as true...
vb Code:
For i = 1 To MyItems.Count If MyItems.Item(i).Start >= CType("08:00", DateTime) Or MyItems.Item(i).End < CType("10:00", DateTime) Then TextBox5.Text = 1 Else TextBox5.Text = 0 End If If MyItems.Item(i).Start >= CType("10:00", DateTime) Or MyItems.Item(i).End < CType("12:00", DateTime) Then TextBox6.Text = 2 Else TextBox6.Text = 0 End If If MyItems.Item(i).Start >= CType("12:00", DateTime) Or MyItems.Item(i).End < CType("14:00", DateTime) Then TextBox7.Text = 4 Else TextBox7.Text = 0 End If If MyItems.Item(i).Start >= CType("14:00", DateTime) Or MyItems.Item(i).End < CType("16:00", DateTime) Then TextBox8.Text = 8 Else TextBox8.Text = 0 End If If MyItems.Item(i).Start >= CType("16:00", DateTime) Or MyItems.Item(i).End < CType("18:00", DateTime) Then TextBox9.Text = 16 Else TextBox9.Text = 0 End If If MyItems.Item(i).Start >= CType("18:00", DateTime) Or MyItems.Item(i).End < CType("20:00", DateTime) Then TextBox10.Text = 32 Else TextBox10.Text = 0 End If If MyItems.Item(i).Start >= CType("20:00", DateTime) Or MyItems.Item(i).End < CType("22:00", DateTime) Then TextBox11.Text = 64 Else TextBox11.Text = 0 End If If MyItems.Item(i).Start >= CType("22:00", DateTime) Or MyItems.Item(i).End < CType("23:59", DateTime) Then TextBox12.Text = 128 Else TextBox12.Text = 0 End If
something's wrong...even if i change the "Or" to " &" it will give me this error
Conversion from string "8:00:00 AM6/25/2007 9:00:00 AM" to type 'Date' is not valid.
Dont use OR or & as they both concatenate the string. Use the AndAlso If block evaluator.
Oh..ok...i change it to...
vb Code:
If MyItems.Item(i).Start >= CType("08:00", DateTime) AndAlso MyItems.Item(i).End < CType("10:00", DateTime) Then TextBox5.Text = 1 Else TextBox5.Text = 0 End If If MyItems.Item(i).Start >= CType("10:00", DateTime) AndAlso MyItems.Item(i).End < CType("12:00", DateTime) Then TextBox6.Text = 2 Else TextBox6.Text = 0 End If If MyItems.Item(i).Start >= CType("12:00", DateTime) AndAlso MyItems.Item(i).End < CType("14:00", DateTime) Then TextBox7.Text = 4 Else TextBox7.Text = 0 End If If MyItems.Item(i).Start >= CType("14:00", DateTime) AndAlso MyItems.Item(i).End < CType("16:00", DateTime) Then TextBox8.Text = 8 Else TextBox8.Text = 0 End If If MyItems.Item(i).Start >= CType("16:00", DateTime) AndAlso MyItems.Item(i).End < CType("18:00", DateTime) Then TextBox9.Text = 16 Else TextBox9.Text = 0 End If If MyItems.Item(i).Start >= CType("18:00", DateTime) AndAlso MyItems.Item(i).End < CType("20:00", DateTime) Then TextBox10.Text = 32 Else TextBox10.Text = 0 End If If MyItems.Item(i).Start >= CType("20:00", DateTime) AndAlso MyItems.Item(i).End < CType("22:00", DateTime) Then TextBox11.Text = 64 Else TextBox11.Text = 0 End If If MyItems.Item(i).Start >= CType("22:00", DateTime) AndAlso MyItems.Item(i).End < CType("23:59", DateTime) Then TextBox12.Text = 128 Else TextBox12.Text = 0 End If Next
then when i set the 3 appointment at 8am to 9am and another from 10am to 11am and another from 12pm to 1pm...
yet all the textbox display is 0.
Hmm..i try using this instead...
if Microsoft.VisualBasic.Strings.Left(MyItems.Item(i).Start.ToString, 2) = "08" or Microsoft.VisualBasic.Strings.Left(MyItems.Item(i).Start.ToString, 2) ="09" then textbox5.text = 1
because i'm trying to use the start and end time to get it,but after i check with it... that the Myitems.item(i).start.Tostring will get me the date then the time display, as in 6/25/2007 12:34 . while the method i try is to get the first 2 number which ended up capture the date instead...
Any idea?
No, the format is ...
If something = whatever AndAlso somethingelse = someotherthing Then
Like what you say ..i got try like #90 but cannot get it,which is why i change it to #91 but also cannot
Because the Myitems.Item(i) output is "date" followed by "time" while my code capture the first 2 which is date only.
Perhaps the vb code in #90 got some problems?
I'm in a lost....
Just compare date/time to date/time. Something like so...
If MyItems.Item(i).Start >= CType(Date.Today.ToShortDateString() & "08:00", DateTime) AndAlso MyItems.Item(i).End < CType(Date.Today.ToShortDateString() & "10:00", DateTime) Then
Hmm...i tried...but it give me this error...
Conversion from string "6/25/200708:00" to type 'Date' is not valid.
ok....i tried out this instead...
If MyItems.Item(i).Start >= CType(Date.Today.ToShortDateString() & " 22:00", DateTime) AndAlso MyItems.Item(i).End < CType(Date.Today.ToShortDateString() & " 24:00", DateTime)
(a space between it)-(" 24:00") Then it will work...but then all the textbox display out as 0.
Is there any problems?
Ok...i manage to get it done through a very tedious way of doing..ended up taking 3/4 of the whole source code...
Hmm....i add a monthly calendar in it ...
is it possible to double click on the date that i want and will be able to run through the process( appointment all these ,etc) during that date itself?
What do you suggest?
Yes. You could also use a DateTimePicker control as it takes up less form space and does essentially the same thing.
Look at the events each control provides and see which is the best for your app's use. ;)
Oh...ok...i discover that the when i change the date of our computer ( right hand corner ) to other date then my form date will also change to that date and display it out ....
and i want the datetimepicker to have that kind of function like as in i choose the date and those information during that day will be display out... searching for clues now...
Hmm.... i can't seem to get it ...
if suppose that i create a textbox and that textbox display / contain the date that i click on the "selected date" of the datetimepicker, and i want the selected date in the textbox to assume as "today" date so that it will take it as though that selected date as today
Any idea?
If your using the dtp then there is no need to pass the values to a textbox. Just use the dtp only.
Hmm..ok...i manage to this work through ..
Adding a button and add in this...
DateTimePicker1.Value = Today
after that, then copy all the code previously and paste on the event under that button which result when click on that selected date and click on that button to activate it...
but it result in changing my desktop date to the selected date and apply in it.
I dont understand why this is so complicated? Why will it change the system date?
Don't know ... but i added a function that it will return back to original date..
Now i require to get 1 week information instead of just "today"...hopefully nothing goes wrong..."Trying hard" ^^
hmm...now got problem getting it which i think is because of the previous code which is not right i suppose...
vb Code:
Today = DateTimePicker1.Value Dim TodaysDate As Date = Today Dim StartDate As DateTime = DateTimePicker1.Value Dim MyCalendar As Outlook.MAPIFolder Dim MyItems As Outlook.Items Dim sToday As String Dim i As Integer Dim dateAndTimeDate As Date dateAndTimeDate = Now sToday = "([Start] >= '" & DateTime.Today.ToShortDateString() & " 00:00AM')" sToday = sToday & " AND ([Start] < '" & DateTime.Today.AddDays(1).ToShortDateString() & " 00:00AM')" MyCalendar = moApp.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar) Console.WriteLine(sToday) MyItems = MyCalendar.Items.Restrict(sToday) MyItems.Sort("[Start]") TextBox1.Text = MyItems.Count & " Appointment " If (MyItems.Count <> 0) Then If (MyItems.Item(1).start.ToString() = Today + " 12:00:00 AM") Then For i = 2 To MyItems.Count ListBox1.Items.Add("Start Time:" & MyItems.Item(i - 1).End.ToString()) ListBox1.Items.Add("End Time:" & MyItems.Item(i).Start.ToString()) If (MyItems.Item(i).start.ToString() = MyItems.Item(i - 1).End.ToString()) Then ListBox1.Items.Remove("Start Time:" & MyItems.Item(i - 1).End.ToString()) ListBox1.Items.Remove("End Time:" & MyItems.Item(i).Start.ToString()) End If Next ListBox1.Items.Add("Start Time:" & MyItems.Item(MyItems.Count).End.ToString()) ListBox1.Items.Add("End Time:" & Today.AddDays(1) & " 0:00:00 AM") For i = 1 To MyItems.Count CheckedListBox1.Items.Add("Start Time:" & MyItems.Item(i).start.ToString() & " ~ End Time:" & MyItems.Item(i).End.ToString()) Next Else ListBox1.Items.Add("Start Time:" & Today & " 0:00:00 AM") ListBox1.Items.Add("End Time:" & MyItems.Item(1).Start.ToString()) For i = 1 To MyItems.Count CheckedListBox1.Items.Add("Start Time:" & MyItems.Item(i).start.ToString() & " ~ End Time:" & MyItems.Item(i).End.ToString()) Next For i = 2 To MyItems.Count ListBox1.Items.Add("Start Time:" & MyItems.Item(i - 1).End.ToString()) ListBox1.Items.Add("End Time:" & MyItems.Item(i).Start.ToString()) If (MyItems.Item(i).start.ToString() = MyItems.Item(i - 1).End.ToString()) Then ListBox1.Items.Remove("Start Time:" & MyItems.Item(i - 1).End.ToString()) ListBox1.Items.Remove("End Time:" & MyItems.Item(i).Start.ToString()) End If Next ListBox1.Items.Add("Start Time:" & MyItems.Item(MyItems.Count).End.ToString()) ListBox1.Items.Add("End Time:" & Today.AddDays(1) & " 0:00:00 AM") End If Else ListBox1.Items.Add("Go Have Some Coffee") CheckedListBox1.Items.Add("~~FREEDOM IS ON THE WAY~~") End If For i = 1 To MyItems.Count If MyItems.Item(i).importance = Outlook.OlImportance.olImportanceHigh Then CheckedListBox1.SetItemCheckState(i - 1, CheckState.Checked) End If
So is there any changes so that the date that i selected will not affect the system date?
Because this code when implented will change the system date( example : i selected 2days later and the system date will take it as selected date is today date)
so what i require is that i select the date from the datetimepicker and the information about the selected date will be display out without having changing the system date.
is there any solution to this?