|
-
Sep 8th, 2000, 07:04 PM
#1
Thread Starter
New Member
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?
-
Sep 8th, 2000, 07:26 PM
#2
_______
<?>
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
-
Sep 8th, 2000, 07:27 PM
#3
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
-
Sep 8th, 2000, 07:47 PM
#4
Thread Starter
New Member
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...)
-
Sep 8th, 2000, 08:54 PM
#5
Fanatic Member
it's probably an API Function
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
-
Sep 8th, 2000, 10:02 PM
#6
"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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|