Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Nov 2001
    Jerusalem, Israel
    Thanked 1 Time in 1 Post

    VB Function (XP/2K)

    I have written the following function. The exact details are not important. (it gives a Jewish date in words for a civil date based on the site calmath that Hans sent me to)/
    The problem is that when I enter the variable dtdate and call the function it only works if I surround the variable with ## -
    If I call FCivil2HebFromDate (4/5/2003) I get the incorrect answer
    BUT if I call FCivil2HebFromDate (#4/5/2003#) it works. that variable is declared as a date.
    Should it need the extra # when I call it?

    Function FCivil2HebFromDate(dtdate As Date, Optional blaftersh3 As Boolean)

    Dim iyear As Integer
    Dim imonth As Integer
    Dim iday As Integer
    Dim blaftersh2 As Boolean

    blaftersh2 = blaftersh3

    iyear = DatePart("yyyy", dtdate)
    imonth = DatePart("m", dtdate)
    iday = DatePart("d", dtdate)
    FCivil2HebFromDate = Fcivil_hebrew(iyear, imonth, iday)

    End Function

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 28 Times in 28 Posts

    Re: VB Function (XP/2K)

    If you want to enter a literal value as argument, you must use the # signs, because otherwise the slashes / get interpreted as division: 4/5 = 0.8, and 4/5/2003 = 0.0003994.
    If you use a variable of type Date, or a text box or a field as argument, the function should interpret the contents as a date.

  3. #3
    4 Star Lounger
    Join Date
    Aug 2002
    Dallas, Texas, USA
    Thanked 0 Times in 0 Posts

    Re: VB Function (XP/2K)

    Just an FYI, if you just want the day, month, and year of a date, then you can use their functions: Day, Month, Year, which return the numeric value of that part of a date. Just reduces the amount of code.....

    You could replace almost all of your code with the following:
    FCivil2HebFromDate = Fcivil_hebrew(Year(dtDate), Month(dtDate), Day(dtDate)

Posting Permissions

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