Results 1 to 6 of 6

Thread: DOW (day of week) function

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Location
    Annapolis MD
    Posts
    4

    Question

    I'm trying to use the DOW function to determine what day of the week a date is; when I run, however, I get an error that says "Compile error: sub or function not defined". Here's the code that I'm using:

    intDayofweek=DOW(txtDate.text)

    dtDayofweek is DIMed as an integer

    Is there something wrong with the way I've coded it? Do I have to have some resource turned on in the project for this function to work?

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Dim myDay as string
    myDay = Format(now,"dddd")
    msgbox myday
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    Guest
    The reason why you get an error is because the function/sub "DOW" does not exist. But you can make a DOW function.

    Try this:

    Code:
    Private Function DOW() As String
    DOW = WeekDay(Date)
    If DOW = 1 Then
    DOW = "Sunday"
    ElseIf DOW = 2 Then
    DOW = "Monday"
    ElseIf DOW = 3 Then
    DOW = "Tuesday"
    ElseIf DOW = 4 Then
    DOW = "Wednesday"
    ElseIf DOW = 5 Then
    DOW = "Thursday"
    ElseIf DOW = 6 Then
    DOW = "Friday"
    ElseIf DOW = 7 Then
    DOW = "Saturday"
    End If
    End Function
    
    Usage:
    
    intDayofWeek = DOW()
    MsgBox intDayofWeek

  4. #4

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Location
    Annapolis MD
    Posts
    4

    Thumbs up Thanks, folks!

    Matthew, the function idea worked perfectly!!!! Thanks to both of you for taking the time to reply!
    (BTW...the DOW thing came off of the MSDN library under DATE AND TIME FUNCTIONS - but I guess it wasn't for VB...)

  5. #5
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    it's probably an API Function
    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

  6. #6
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    "DOW" is an old dBase (now FoxPro) function. As Matthew Gates indicates, the name of this function in VB is Weekday, which returns a value between 1 and 7 (1=Sunday, 7=Saturday). To get the name of the day of the week, in instead of doing the nested Ifs like Matthew, you can use the WeekdayName function:
    Code:
    Dim strDayName As String
    strDayName = WeekdayName(Weekday(Now))
    "It's cold gin time again ..."

    Check out my website here.

Posting Permissions

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



Click Here to Expand Forum to Full Width