Wilder1626
asked on
VB6 - Add dates to MSHFlexgrid by
Hi.
I need your help on a macro.
I have an MSHFlexgrid1 that i need to populate based on 3 different criteria.
No1: Start date
No2 How many Weeks
No3: Days requested
Let's take below picture as an example:
I have the start date of : 28-08-2017
I also have the number of week set to 10
And i also have the "Tuesday" day checked
What i would expect to see in the MSHFlexgrid1 is to add 10 rows where i would see the following 10 Tuesday dates starting on the Starting date of 28-08-2017 .
That would be:
29-08-2017
05-09-2017
12-09-2017
13-09-2017
19-09-2017
26-09-2017
03-10-2017
10-10-2017
17-10-2017
24-10-2017
I could check multiple different days also. Based on the days i check, it would add the the dates in the MSHFlexgrid1 in to LaneStartDateTime column.
How can i do that?
Thank you for your help.
date_conversion.zip
I need your help on a macro.
I have an MSHFlexgrid1 that i need to populate based on 3 different criteria.
No1: Start date
No2 How many Weeks
No3: Days requested
Let's take below picture as an example:
I have the start date of : 28-08-2017
I also have the number of week set to 10
And i also have the "Tuesday" day checked
What i would expect to see in the MSHFlexgrid1 is to add 10 rows where i would see the following 10 Tuesday dates starting on the Starting date of 28-08-2017 .
That would be:
29-08-2017
05-09-2017
12-09-2017
13-09-2017
19-09-2017
26-09-2017
03-10-2017
10-10-2017
17-10-2017
24-10-2017
I could check multiple different days also. Based on the days i check, it would add the the dates in the MSHFlexgrid1 in to LaneStartDateTime column.
How can i do that?
Thank you for your help.
date_conversion.zip
ASKER
ASKER
I also see that it only do 1day of the week. But i may select more than 1 day. Ex, if i select Tuesday and Friday, it should pull dates for Tuesday and Friday for the next 10 weeks. Etc...
We are almost there. :)
We are almost there. :)
ASKER
This should fix the problems you found.
If you choose a second (or subsequent) day, how do you want the results to appear? Let's assume you chose Friday and Saturday. Do you want 10 Fridays followed 10 Saturdays, or do you want Friday, Saturday, Friday, Saturday, etc.?
29053296a.zip
If you choose a second (or subsequent) day, how do you want the results to appear? Let's assume you chose Friday and Saturday. Do you want 10 Fridays followed 10 Saturdays, or do you want Friday, Saturday, Friday, Saturday, etc.?
29053296a.zip
ASKER
Let me try this,
For your last question, if i can have Friday, Saturday, Friday, Saturday, etc.that would be very good.
For your last question, if i can have Friday, Saturday, Friday, Saturday, etc.that would be very good.
ASKER
I've got this Run Time error 9 where strParts "SubScript out of range"
For some reason, i cant fix it. Looks to be on the first date entered in the grid.
strParts = Split(dteStart, "/")
MSHFlexGrid1.TextMatrix(1, 10) = Format(strParts(1), "00") & "-" & Format(strParts(0), "00") & "-" & Format(strParts(2), "00")
For some reason, i cant fix it. Looks to be on the first date entered in the grid.
What date was in start_date_value?
ASKER
It is: 28-08-2017
funny thing is that when i do below code, it works
funny thing is that when i do below code, it works
MSHFlexGrid1.TextMatrix(1, 10) = Format(strParts(0), "dd-mm-yyyy")
I think I've got it figured out, but let me ask you another question. Do you actually want the count_rows textbox to be displayed, or were you just using it as a variable?
ASKER
I was just using it as a variable. I wont use it anymore.
Another question. Given that today is Tuesday, if you selected Sunday, Friday and Saturday, then currently the output would look like the following where the first Sunday after the starting date is shown, followed by the first Friday after the starting date (which is earlier calendar-wise) and then the first Saturday after the starting date. Is that OK?
If not (and I don't necessarily want to make more work for myself) I think I could show it as
01-09-2017
02-09-2017
03-09-2017
Or perhaps even
03-09-2017
08-09-2017 -> the first Friday after 03-09-2017
09-09-2017
If not (and I don't necessarily want to make more work for myself) I think I could show it as
01-09-2017
02-09-2017
03-09-2017
Or perhaps even
03-09-2017
08-09-2017 -> the first Friday after 03-09-2017
09-09-2017
ASKER
Yes, that would be perfect.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes, that would be perfect.Which one?
ASKER
sorry, its perfect the way you did it already. I'm testing it right now and so far, this is awesome!!!
ASKER
Thank you so much for your help. This is very very good.
You're welcome and I'm glad I was able to help.
If you expand the “Full Biography” section of my profile you'll find links to some articles I've written that may interest you.
Marty - Microsoft MVP 2009 to 2017
Experts Exchange MVE 2015
Experts Exchange Top Expert Visual Basic Classic 2012 to 2017
If you expand the “Full Biography” section of my profile you'll find links to some articles I've written that may interest you.
Marty - Microsoft MVP 2009 to 2017
Experts Exchange MVE 2015
Experts Exchange Top Expert Visual Basic Classic 2012 to 2017
29053296.zip