Results 1 to 3 of 3

Thread: Fill Property Let with function
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    May 2008
    Location
    Austria
    Posts
    1,087
    Post Thanks / Like
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)

    Default Fill Property Let with function

    Hi guys,
    I am just wondering how I could fill a property let with a function.

    for example I got following function

    Code:
    Function KW_DIN(Datum As Date) As Integer
        '''geklaut ;o)
        ''von Christoph Kremer, Aachen
        'Berechnt die KW nach DIN 1355
        'http://www.office-loesung.de/fpost675805.php#675805
    
        Dim t&
        t = DateSerial(Year(Datum + (8 - Weekday(Datum)) Mod 7 - 3), 1, 1)
        KW_DIN = (Datum - t - 3 + (Weekday(t) + 1) Mod 7) \ 7 + 1
    End Function
    And I like to fill a property Let statement in a class module with this function

    this I got in the Class module

    Private m_KW as integer


    Code:
    Property Let Kalenderwoche(datKW As Date)
        m_KW = KW_DIN(datKW)
    End Property
    is this possible? Or is that not really how you should do that?

    Thanks for your input!
    Silentwolf



    I use MS Office 2010 and Windows 7

  2. #2
    Board Regular Jaafar Tribak's Avatar
    Join Date
    Dec 2002
    Location
    Larache--Morocco
    Posts
    7,398
    Post Thanks / Like
    Mentioned
    40 Post(s)
    Tagged
    3 Thread(s)

    Default Re: Fill Property Let with function

    Hi,

    Is this what you want ? :

    In the Class Module :
    Code:
    Private m_KW As Integer
    
    Property Let Kalenderwoche(datKW As Date)
        
        Dim t&
        t = DateSerial(Year(datKW + (8 - Weekday(datKW)) Mod 7 - 3), 1, 1)
        m_KW = (datKW - t - 3 + (Weekday(t) + 1) Mod 7) \ 7 + 1
    
    
    End Property
    Office/Excel 2010 64Bits -- Win10 64Bits

    Common sense is not so common.


    http://photo-larache.blogspot.com/

  3. #3
    Board Regular
    Join Date
    May 2008
    Location
    Austria
    Posts
    1,087
    Post Thanks / Like
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Fill Property Let with function

    Hi,
    thanks Jaafar .. but I am still not really getting anywhere here..
    I have a userform where I like to pick a date that should then fill the Kalenderwoche (Calendar Week) but somehow I am getting not the right answer..

    I got this sub in the class module

    Code:
    Sub AddToTimeSheet()
    
        Range("G1").Value = Me.Mitarbeiter
        Range("B1").Value = Me.Kalenderwoche
     
        
    End Sub
    And a userform with a datepicker now I like after I click the ok button on the userform that my addToList sub of the class module fires..

    Is this a bit clearer now?
    Silentwolf



    I use MS Office 2010 and Windows 7

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •