Erm..ya i know..but...
If u see #59, the display isn't right and it isn;t check high importance items.
which is why i dun know why it becomes like this...
Printable View
Erm..ya i know..but...
If u see #59, the display isn't right and it isn;t check high importance items.
which is why i dun know why it becomes like this...
Oh I see now. Because the collection is zero based and your loop is one based so they are all off by one. :)
Ya but then...
i got add another line and try before but there's still error
vb Code:
For i = 1 To MyItems.Count If MyItems.Item(i).importance = Outlook.OlImportance.olImportanceHigh Then CheckedListBox1.SetItemChecked(i, True) CheckedListBox1.SetItemChecked(i - 1, True) End if
For example: i got 3 appointment.
1st appointment got importance high
2nd appointment is normal
3rd appointment got importance high
What it displayed out:
Start & End time of 1st appointment is been checked
Start & End time of 2nd appointment is been checked
Error is that it should be 3rd appointment Start & End checked and not 2nd appointment.
From what i think it's probably because of the items.sort?
Any idea?
Because of the i-1 index. Just leave it for the next iteration otherwise you will want to loop by twos.
Actually i wanted both start time and end time to be checked if there's high importance for that appointment if not then start time of the appointment with high importance checked is also fine with me but i can;t seem to get it.
Wondering why~
If you set the check on each iteration if it passes the inportance test then you will have what you want. If you loop by twos (Step 2) you can also get it by using the i-1 index like you previously had.
I was thinking that if possible looping the start & End time together then that code that i use in #55 will maybe work, guess i will try it out tomorrow. If still unable to work then maybe i will display the whole code so maybe you will know if there's something wrong with my code.
Just post your loop as you are currently using it.
Like what you say, i need to try so that i can learn more and thus i'm trying my best to figure it out and now after i loop both the start time and end time together , it finally work....phew....guess seperating both start time and end could cause alot of problems... T.T
Well, after i get the free available time done, i wanna try to have better improvement on appointment time this time is that i will have the appointment time with the link of binary, example...
0000 0001 is from 08: 00 ~ 10: 00
0000 0010 is from 10: 00 ~ 12: 00
0000 0100 is from 12: 00 ~ 14: 00
and so on...
if i got an appointment that is from 10: 00 to 13: 00
then it will display 0000 0110
So first thing is grouping timing of the day should be the first thing right?Grouping the timing 2hours each time starting from 08:00, but then i do not know how to start...
Any ideas?
So you are saying that you want to group appointments every 2 hours starting from 8am?
Not really appointments time, to be exact is the timing starting from 08:00 till 24: 00 because i think nobody going to have a appointment before 08: 00 that early... so i will cut short to starting time of 08: 00. Binary stuff....
0000 0001 is from 08: 00 ~ 10: 00
0000 0010 is from 10: 00 ~ 12: 00
0000 0100 is from 12: 00 ~ 14: 00
0000 1000 is from 14: 00 ~ 16: 00
0001 0000 is from 16: 00 ~ 18: 00
0010 0000 is from 18: 00 ~ 20: 00
0100 0000 is from 20: 00 ~ 22: 00
1000 0000 is from 22: 00 ~ 24: 00
and these are not appointment time.It's more like a time reference, but if a appointment is within that time period like ... from 10: 00 to 13: 00 then it will display "0000 0110" in a textbox or label. And yupz...Grouping of 2 hours is needed.
Since there arent too many entries possible, you can just use a select case block to evaluate the time and set the labels text property accordingly to your binary requirements.
My idea is that if it is possible that ...
If appointment start time => 08: 00 or appointment End time< 10: 00
Then textbox1.text = 1
Else textbox1.text = 0
and keep on using ...
If appointment start time => 10: 00 or appointment End time< 12: 00
Then textbox2.text = 2
Else textbox2.text = 0
and using the last textbox to add all the values up and convert to binary...but then i have not try before... don't even know whether if there's this kind of conditions exist...( i mean the If appointment start time => 10: 00 or appointment End time< 12: 00 in the first place)...
What do you think?
But of course, just do like you have already done.
If MyItems..Item(i).Start >= Date.ToString & " " & 8:00" Then
etc.
I tried... but it gives me error
vb Code:
if MyItems.Item(i).Start >= Date.Today.TimeOfDay.Hours 08: 00 or Myitems.Item(i).End < Date.Today.TimeOfDay.Hours 10:00 then TextBox5.Text = 1 End If
It's the time that gives error...
Any idea?
Whats the error? Try placing the hour time wrapped with double quotes.
Hmm.. ok...
vb Code:
If MyItems.Item(i).Start >= Date.Today.TimeOfDay.Hours & "08: 00" Or MyItems.Item(i).End < Date.Today.TimeOfDay.Hours & "10: 00" Then TextBox5.Text = 1 End If
and it gives me error saying...Conversion from string "008: 00" to type 'Date' is not valid.
Something liek this should work.
CType(Date.Today.TimeOfDay.Hours & "08: 00", DateTime)
Oh...after trying it out...
vb Code:
If MyItems.Item(i).Start >= CType(Date.Today.TimeOfDay.Hours & "08: 00", DateTime) Or CType(Date.Today.TimeOfDay.Hours & "10: 00", DateTime) Then TextBox5.Text = 1 End If
it gives me another error...
Operator 'Or' is not defined for types 'Object' and 'Date'.
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?