Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

using calendar control and msflexgrid HELP!!!

Last post 05-04-2008 12:04 AM by breakdance89. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 05-01-2008 2:57 PM

    • breakdance89
    • Not Ranked
    • Joined on 05-01-2008
    • United Kingdom
    • New Member
    • Points 20

    using calendar control and msflexgrid HELP!!!

    hi i am having a big trouble with calendar control and msflexgrid. my objective is when the date is selected it would add onto the grid on the right collum such as if the date selected is 01/05/2008 (Thursday) once selected it would display onto the grid as following. the grid is 9 collums wide. this is how the rota looks like. i want the code to identify the column and display it on the right column. the problem is of my code is that when the date changes it moves forward the days. like Monday - 28/04/08 that changes to 29/04/08.

    ......................................................................................................................................................................

    name/Day....Monday....Tuesday....Wednesday....thursday....Friday....Saturday....Sunday....Total Hours

    Date............28/04/08...29/04/08.....30/04/08.......1/05/08......2/05/08....3/05/08.....4/05/08

    Name

    Name

    Name

    ........................................................................................................................................................................

    My sample code. I did not use the calendar control yet because I dont know how. I would be really appreciated if you guys could help me out. thanks in advance

        Dim a As Integer
        For a = 1 To 7
        grdRota.TextMatrix(a, 1) = Date - 3
        Next a
        For a = 1 To 7
        grdRota.TextMatrix(a, 2) = Date - 2
        Next a
        For a = 1 To 7
        grdRota.TextMatrix(a, 3) = Date - 1
        Next a
        For a = 1 To 7
        grdRota.TextMatrix(a, 4) = Date
        Next a
        For a = 1 To 7
        grdRota.TextMatrix(a, 5) = Date + 1
        Next a
        For a = 1 To 7
        grdRota.TextMatrix(a, 6) = Date + 2
        Next a
        For a = 1 To 7
        grdRota.TextMatrix(a, 7) = Dat

    • Post Points: 10
  • 05-02-2008 2:51 PM In reply to

    • Jugatsu
    • Top 500 Contributor
    • Joined on 02-15-2006
    • Member
    • Points 290

    Re: using calendar control and msflexgrid HELP!!!

    Hey, I'm not 100% sure what you want exactly. 

    If you want to select a date then loop back to Monday then fill the grid with Monday - Sundays date

    the code below should do it for you

        Dim tDate As Date
        tDate = Now     ' use todays date as example
        Do While Weekday(tDate) <> vbMonday
            tDate = DateAdd("d", -1, tDate)
        Loop
       
        Dim a As Integer
        For a = 1 To 7
            grdRota.TextMatrix(a, 1) = DateAdd("d", a - 1, tDate)
        Next a

     

    • Post Points: 10
  • 05-02-2008 3:16 PM In reply to

    • breakdance89
    • Not Ranked
    • Joined on 05-01-2008
    • United Kingdom
    • New Member
    • Points 20

    Re: using calendar control and msflexgrid HELP!!!

    Yes that is what I want. but the code you have gave to me. only loops Monday. does not loop the whole week for appropriate day. and also it should identify the day such as Monday was 28/04/2008 then Tuesday was 29/04/2008/ I can provide all program if you would like to have a look. this is for my IVA project in college. thanks for your reply.  

    • Post Points: 5
  • 05-04-2008 12:04 AM In reply to

    • breakdance89
    • Not Ranked
    • Joined on 05-01-2008
    • United Kingdom
    • New Member
    • Points 20

    Re: using calendar control and msflexgrid HELP!!!

     your code was right. thanks you. just a few changes i made to suit my needs.

     

    Dim tDate As Date
        tDate = Now     ' use todays date as example
        Do While Weekday(tDate) <> vbMonday
            tDate = DateAdd("d", -1, tDate)
        Loop
        
        Dim a As Integer
        For a = 1 To 7
            tDate = Format(tDate, "d/m/yy")
            grdRota.TextMatrix(1, a) = DateAdd("d", a - 1, tDate)
          'Text2.Text = Format(tDate, "d/m/yy")
        Next a

    • Post Points: 5
Page 1 of 1 (4 items)