Response.Write Date() problems

Response.Write Date() problems

am 20.09.2007 22:45:38 von jp2code

I'm trying to display a weekly calendar with the month and year on top and
the current date in an alternate color, but nothing prints out on my test
page when viewed in IE7.

Is there something fundamentally wrong with my code, is it my browser, or
does this not show up when displayed on my PC?

Here is all of the code (nice and small):

<%@ Language="VBSCRIPT"%>
"http://www.w3.org/TR/html4/strict.dtd">
<%
Dim i As Integer
Response.Write("

")
For i = 1 To 7
Response.Write("")
Next i
Response.Write("
start1" & Month(Date()) & "
" & Year(Date()) & "end1
"
& Day(Date()) & "
")
%>


Weekly Calendar







<%
Dim i As Integer
For i = 1 To 7
Response.Write("")
Next
%>

start2<% Response.Write(Month(Date()) &
" " & Year(Date())) %>end2
If (i = WeekDay(Date())) Then
Response.Write("day")
Else
Response.Write("reg")
End If
Response.Write(""">" & Day(Date()) & "






<%
Dim i As Integer
For i = 1 To 7
Response.Write("")
Next
%>

start3<% Response.Write(Month(Date()) &
" " & Year(Date())) %>end3
""">" & Day(Date()) & "


Re: Response.Write Date() problems

am 20.09.2007 23:14:27 von reb01501

jp2code wrote:
> I'm trying to display a weekly calendar with the month and year on
> top and the current date in an alternate color, but nothing prints
> out on my test page when viewed in IE7.
>
> Is there something fundamentally wrong with my code, is it my
> browser, or does this not show up when displayed on my PC?
>
> Here is all of the code (nice and small):
>

If I was going to debug this, I would start by commenting out everything
until I got some output in the browser, then adding stuff back in until it
broke again.


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Re: Response.Write Date() problems

am 20.09.2007 23:15:38 von Jon Paal

these lines are bogus:

--> Dim i As Integer

use :

Dim i 'As Integer

not sure what you're trying to get, but this line is erroneous:

-->Response.Write(""

can't put a formula in a write statement

Re: Response.Write Date() problems

am 20.09.2007 23:27:45 von jp2code

This *is* my cut down version.

There are just 3 ways of showing the same thing - each way failed.

All this example is trying to do is populate a table using Response.Write.

I'll look into Jon Paal's answer; it may have solved the problem.

"Bob Barrows [MVP]" wrote in message
news:Opvr6s8%23HHA.1164@TK2MSFTNGP02.phx.gbl...
> jp2code wrote:
>> I'm trying to display a weekly calendar with the month and year on
>> top and the current date in an alternate color, but nothing prints
>> out on my test page when viewed in IE7.
>>
>> Is there something fundamentally wrong with my code, is it my
>> browser, or does this not show up when displayed on my PC?
>>
>> Here is all of the code (nice and small):
>>
>
> If I was going to debug this, I would start by commenting out everything
> until I got some output in the browser, then adding stuff back in until it
> broke again.
>
>
> --
> Microsoft MVP - ASP/ASP.NET
> Please reply to the newsgroup. This email account is my spam trap so I
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"
>

Re: Response.Write Date() problems

am 20.09.2007 23:46:08 von jp2code

Mr. Paal,

I removed the "As Integer" section, still no output, so I edited the code to
this version (below) which still does not work. All it outputs are two
tables (not 3): "start2end2" and "start3end3" - but at least with the
"start3end3" table, I can also see the second row.

Can you get this to display in a web page? Here is the code:

<%@ Language="VBSCRIPT"%>
"http://www.w3.org/TR/html4/strict.dtd">
<%
Dim sun, mon, tue, wed, thr, fri, sat, monthYear
sun = (1 = WeekDay(Date())) ? "day" : "reg"
mon = (2 = WeekDay(Date())) ? "day" : "reg"
tue = (3 = WeekDay(Date())) ? "day" : "reg"
wed = (4 = WeekDay(Date())) ? "day" : "reg"
thr = (5 = WeekDay(Date())) ? "day" : "reg"
fri = (6 = WeekDay(Date())) ? "day" : "reg"
sat = (7 = WeekDay(Date())) ? "day" : "reg"
monthYear = Month(Date()) & " " & Year(Date())
%>


Weekly Calendar







<%
Dim i
For i = 1 To 7
Response.Write("")
Next
%>

start2<% Response.Write(monthYear)
%>end2
If (i = WeekDay(Date())) Then
Response.Write("day")
Else
Response.Write("reg")
End If
Response.Write(""">" & Day(Date()) & "














start3<% Response.Write(monthYear)
%>end3
><% Response.Write(WeekDay(Date())) %> ><% Response.Write(mon) %> ><% Response.Write("18") %> ><%=wed%> ><% Response.Write(WeekDay("September 20, 2007"))
%>
<%=fri%> ><% Response.Write(WeekDay("September 22, 2007"))
%>




"Jon Paal [MSMD]" wrote in message
news:13f5ontdc8p6gbe@corp.supernews.com...
>
> these lines are bogus:
>
> --> Dim i As Integer
>
> use :
>
> Dim i 'As Integer
>
> not sure what you're trying to get, but this line is erroneous:
>
> -->Response.Write(" > """>"
>
> can't put a formula in a write statement
>
>
>
>

Re: Response.Write Date() problems

am 21.09.2007 00:01:22 von Jon Paal

these lines are bogus:

sun = (1 = WeekDay(Date())) ? "day" : "reg"
....

not sure what you're trying to get here..
The weekday number can be obtained as "WeekDay(Date())"

example:

Dim MyDate, MyWeekDay
MyDate = #October 19, 1962# ' Assign a date.
MyWeekDay = Weekday(MyDate) ' MyWeekDay contains 6 because MyDate represents a Friday.
"jp2code" wrote in message news:OYD5l%238%23HHA.980@TK2MSFTNGP06.phx.gbl...
> Mr. Paal,
>
> I removed the "As Integer" section, still no output, so I edited the code to this version (below) which still does not work. All
> it outputs are two tables (not 3): "start2end2" and "start3end3" - but at least with the "start3end3" table, I can also see the
> second row.
>
> Can you get this to display in a web page? Here is the code:
>
> <%@ Language="VBSCRIPT"%>
>
> <%
> Dim sun, mon, tue, wed, thr, fri, sat, monthYear
> sun = (1 = WeekDay(Date())) ? "day" : "reg"
> mon = (2 = WeekDay(Date())) ? "day" : "reg"
> tue = (3 = WeekDay(Date())) ? "day" : "reg"
> wed = (4 = WeekDay(Date())) ? "day" : "reg"
> thr = (5 = WeekDay(Date())) ? "day" : "reg"
> fri = (6 = WeekDay(Date())) ? "day" : "reg"
> sat = (7 = WeekDay(Date())) ? "day" : "reg"
> monthYear = Month(Date()) & " " & Year(Date())
> %>
>
>
> Weekly Calendar
>
>
>
>
>


>
>
> <%
> Dim i
> For i = 1 To 7
> Response.Write("")
> Next
> %>
>
>
start2<% Response.Write(monthYear) %>end2
> If (i = WeekDay(Date())) Then
> Response.Write("day")
> Else
> Response.Write("reg")
> End If
> Response.Write(""">" & Day(Date()) & "

>

>
>
>
>
>
>
>
>
>
>
>
>
start3<% Response.Write(monthYear) %>end3
><% Response.Write(WeekDay(Date())) %>><% Response.Write(mon) %>><% Response.Write("18") %>><%=wed%>><% Response.Write(WeekDay("September 20, 2007")) %><%=fri%>><% Response.Write(WeekDay("September 22, 2007")) %>

>
>
>
> "Jon Paal [MSMD]" wrote in message news:13f5ontdc8p6gbe@corp.supernews.com...
>>
>> these lines are bogus:
>>
>> --> Dim i As Integer
>>
>> use :
>>
>> Dim i 'As Integer
>>
>> not sure what you're trying to get, but this line is erroneous:
>>
>> -->Response.Write(""
>>
>> can't put a formula in a write statement
>>
>>
>>
>>
>
>

Re: Response.Write Date() problems

am 21.09.2007 00:55:28 von Bob Lehmann

>> sun = (1 = WeekDay(Date())) ? "day" : "reg"
There is not a ternary operator in VbScript.

Bob Lehmann

"jp2code" wrote in message
news:OYD5l%238%23HHA.980@TK2MSFTNGP06.phx.gbl...
> Mr. Paal,
>
> I removed the "As Integer" section, still no output, so I edited the code
to
> this version (below) which still does not work. All it outputs are two
> tables (not 3): "start2end2" and "start3end3" - but at least with the
> "start3end3" table, I can also see the second row.
>
> Can you get this to display in a web page? Here is the code:
>
> <%@ Language="VBSCRIPT"%>
> > "http://www.w3.org/TR/html4/strict.dtd">
> <%
> Dim sun, mon, tue, wed, thr, fri, sat, monthYear
> sun = (1 = WeekDay(Date())) ? "day" : "reg"
> mon = (2 = WeekDay(Date())) ? "day" : "reg"
> tue = (3 = WeekDay(Date())) ? "day" : "reg"
> wed = (4 = WeekDay(Date())) ? "day" : "reg"
> thr = (5 = WeekDay(Date())) ? "day" : "reg"
> fri = (6 = WeekDay(Date())) ? "day" : "reg"
> sat = (7 = WeekDay(Date())) ? "day" : "reg"
> monthYear = Month(Date()) & " " & Year(Date())
> %>
>
>
> Weekly Calendar
> />
>
>
>
>


>
>
> <%
> Dim i
> For i = 1 To 7
> Response.Write("")
> Next
> %>
>
>
start2<% Response.Write(monthYear)
> %>end2
> If (i = WeekDay(Date())) Then
> Response.Write("day")
> Else
> Response.Write("reg")
> End If
> Response.Write(""">" & Day(Date()) & "

>

>
>
>
>
>
>
>
>
>
>
>
>
start3<% Response.Write(monthYear)
> %>end3
><% Response.Write(WeekDay(Date())) %>><% Response.Write(mon) %>><% Response.Write("18") %>><%=wed%>><% Response.Write(WeekDay("September 20, 2007"))
> %>
<%=fri%>><% Response.Write(WeekDay("September 22, 2007"))
> %>

>
>
>
> "Jon Paal [MSMD]" wrote in message
> news:13f5ontdc8p6gbe@corp.supernews.com...
> >
> > these lines are bogus:
> >
> > --> Dim i As Integer
> >
> > use :
> >
> > Dim i 'As Integer
> >
> > not sure what you're trying to get, but this line is erroneous:
> >
> > -->Response.Write(" > > """>"
> >
> > can't put a formula in a write statement
> >
> >
> >
> >
>
>

Re: Response.Write Date() problems

am 21.09.2007 09:46:48 von exjxw.hannivoort

Jon Paal [MSMD] wrote on 21 sep 2007 in
microsoft.public.inetserver.asp.general:

> these lines are bogus:
>
> sun = (1 = WeekDay(Date())) ? "day" : "reg"
> ...
>
> not sure what you're trying to get here..
> The weekday number can be obtained as "WeekDay(Date())"
>

If the OP corrects that error,
using Date() again and again
could get the OP two different dates
in the same execution once in a while

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Re: Response.Write Date() problems

am 21.09.2007 11:07:41 von Anthony Jones

"Evertjan." wrote in message
news:Xns99B2637CD6EACeejj99@194.109.133.242...
> Jon Paal [MSMD] wrote on 21 sep 2007 in
> microsoft.public.inetserver.asp.general:
>
> > these lines are bogus:
> >
> > sun = (1 = WeekDay(Date())) ? "day" : "reg"
> > ...
> >
> > not sure what you're trying to get here..
> > The weekday number can be obtained as "WeekDay(Date())"
> >
>
> If the OP corrects that error,
> using Date() again and again
> could get the OP two different dates
> in the same execution once in a while
>


Don't you mean once in a blue moon.

--
Anthony Jones - MVP ASP/ASP.NET

Re: Response.Write Date() problems

am 21.09.2007 11:25:39 von Anthony Jones

"jp2code" wrote in message
news:OYD5l%238%23HHA.980@TK2MSFTNGP06.phx.gbl...
> Mr. Paal,
>
> I removed the "As Integer" section, still no output, so I edited the code
to
> this version (below) which still does not work. All it outputs are two
> tables (not 3): "start2end2" and "start3end3" - but at least with the
> "start3end3" table, I can also see the second row.
>
> Can you get this to display in a web page? Here is the code:
>
> <%@ Language="VBSCRIPT"%>
> > "http://www.w3.org/TR/html4/strict.dtd">
> <%
> Dim sun, mon, tue, wed, thr, fri, sat, monthYear
> sun = (1 = WeekDay(Date())) ? "day" : "reg"
> mon = (2 = WeekDay(Date())) ? "day" : "reg"
> tue = (3 = WeekDay(Date())) ? "day" : "reg"
> wed = (4 = WeekDay(Date())) ? "day" : "reg"
> thr = (5 = WeekDay(Date())) ? "day" : "reg"
> fri = (6 = WeekDay(Date())) ? "day" : "reg"
> sat = (7 = WeekDay(Date())) ? "day" : "reg"
> monthYear = Month(Date()) & " " & Year(Date())
> %>
>
>
> Weekly Calendar
> />
>
>
>
>


>
>
> <%
> Dim i
> For i = 1 To 7
> Response.Write("")
> Next
> %>
>
>
start2<% Response.Write(monthYear)
> %>end2
> If (i = WeekDay(Date())) Then
> Response.Write("day")
> Else
> Response.Write("reg")
> End If
> Response.Write(""">" & Day(Date()) & "

>

>
>
>
>
>
>
>
>
>
>
>
>
start3<% Response.Write(monthYear)
> %>end3
><% Response.Write(WeekDay(Date())) %>><% Response.Write(mon) %>><% Response.Write("18") %>><%=wed%>><% Response.Write(WeekDay("September 20, 2007"))
> %>
<%=fri%>><% Response.Write(WeekDay("September 22, 2007"))
> %>

>
>
>

Is this what you are trying to do:-

"http://www.w3.org/TR/html4/strict.dtd">
<%
Dim i
Dim mdatToday : mdatToday = Date()

Function GetTDClass(rlWeekDay)
If rlWeekDay = WeekDay(mdatToday) Then
GetTDClass = "day"
Else
GetTDClass = "reg"
End If
End Function

Function GetMonthYear()
GetMonthYear = Month(mdatToday) & " " & Year(mdatToday)
End Function

Function DayFromWeekDay(rlWeekDay)
DayFromWeekDay = Day(mdatToday - (WeekDay(mdatToday) - rlWeekDay))
End Function

%>


Weekly Calendar







<%
For i = 1 To 7
Response.Write "" & vbCrLf
Next
%>

<%=GetMonthYear()%>
" & DayFromWeekDay(i) &
"




An often overlooked feature of VBScript (esp. by ASPers) is the Function.

--
Anthony Jones - MVP ASP/ASP.NET

Re: Response.Write Date() problems

am 21.09.2007 16:32:51 von jp2code

That is exactly what I was trying to do!

I suppose my ASP pages need to start being coded in JScript; the syntax
differences between JavaScript and VBScript keep getting me into trouble.

Thanks!

"Anthony Jones" wrote:
> Is this what you are trying to do:
>
> > "http://www.w3.org/TR/html4/strict.dtd">
> <%
> Dim i
> Dim mdatToday : mdatToday = Date()
>
> Function GetTDClass(rlWeekDay)
> If rlWeekDay = WeekDay(mdatToday) Then
> GetTDClass = "day"
> Else
> GetTDClass = "reg"
> End If
> End Function
>
> Function GetMonthYear()
> GetMonthYear = Month(mdatToday) & " " & Year(mdatToday)
> End Function
>
> Function DayFromWeekDay(rlWeekDay)
> DayFromWeekDay = Day(mdatToday - (WeekDay(mdatToday) - rlWeekDay))
> End Function
>
> %>
>
>
> Weekly Calendar
> > />
>
>
>
>


>
>
> <%
> For i = 1 To 7
> Response.Write "" & vbCrLf
> Next
> %>
>
>
<%=GetMonthYear()%>
" & DayFromWeekDay(i)
> &
> "

>
>
>
> An often overlooked feature of VBScript (esp. by ASPers) is the Function.
>
> --
> Anthony Jones - MVP ASP/ASP.NET
>
>