If Statement - Im trying !

M

Mick

I really am a newbie at this so please bare with me. I am trying to introduce
an "IF" statement into an asp and although it sort of works The first part of
the statement seems to work i.e.
dtHoursDifferent = (dtSecondTime-dtFirstTime)%>

gives me the correct sum of the hours from the two fields, and places the
correct sum in the field dtHoursDifferent. The "IF" part is not correct as it
places a "0" or "1" at the top of the page if the criteria is met (or not)
and not in the correct field of dtHoursDifferent.

Am I trying the impossible, or am I so far away, I should start again?
--------code starts---------
dtHoursDifferent = (dtSecondTime-dtFirstTime)%>
<%if dtHoursDifferent <4 then %>0<%
else %>1<%
end if%>

Thanks for helping.
 
T

Thomas A. Rowe

<%
dtHoursDifferent = (dtSecondTime-dtFirstTime)

if dtHoursDifferent <4 then
dtHoursDifferent= 0
else
dtHoursDifferent= 1
end if
%>

--
==============================================
Thomas A. Rowe
Microsoft MVP - FrontPage

http://www.Ecom-Data.com
==============================================
 
M

Mick

Thomas, hope this thread is still open, I would like to develop it just one
step
In your reply you gave me
<%
dtHoursDifferent = (dtSecondTime-dtFirstTime)
if dtHoursDifferent <3.5 then
dtHoursDifferent= 0
else
dtHoursDifferent= 1
end if
%>
This works fine thankyou, but how do I introduce a new parameter, for example
<%
dtHoursDifferent = (dtSecondTime-dtFirstTime)

if dtHoursDifferent <3.5 then
dtHoursDifferent= 0

OR IF dtHoursDifferent =6 then
dtHoursDifferent=6

else
dtHoursDifferent= 1
end if
%>
So its really an"IF" or "IF" before the "Else" statement. Again many thanks
for your help.
 
M

Mick

Ron, absolutely spot on!! Many thanks for your reply Again it worked first
time. Kind regards Mick
 
M

Mick

One last thing. With some of the calculations produced from varaitions in the
code so far, working out percentages of the number "dtHoursDifferent" has
produced many decimal places. I would like to format the result of
"dtHoursDifferent" to 2 decimal places, any help woulld be appreciated
I would imagine something like below as a clue as to what I am attempting
(without success)
<%
dtHoursDifferent = (dtSecondTime-dtFirstTime)
Format (dtHoursdifferent) "0.00"
%>
Thanks again for your assistance
Mick
 
M

Mick

Hi again, this is all working well thanks to the MVP´s but as the site
develops more issues, sorry.

The calculated field "dtHoursDifferent" is fine, but how can I call up this
field result in another page, so as the result on the original page
(OldPage.asp), also appears on the new page (NewPage.asp).

I want to write in NewPage.asp something like

dtHoursDifferent= request.OldPage.asp("HoursDifferent")

but how do I identify the page or form where the resuts are i.e. the two
pages are not linked in any way.
Thanks again, Mick


:
,> <%
 
T

Thomas A. Rowe

Store the value in a Session Object

Session("dthour") = HoursDifferent


Then on the new page use the following to display:

<%=Session("dthour")%>

--
==============================================
Thomas A. Rowe
Microsoft MVP - FrontPage

http://www.Ecom-Data.com
==============================================
 
R

Ronx

In the original page after all the calculations:

session("differenthours") = dtHoursDifferent


In the new pages

dtHoursDifferent = session("differenthours")

This will work provided all the pages viewed are in the same web, all
are .asp pages, and the user takes less than 20 minutes to move from one
page to another (20 minutes is the usual time for a session to time
out, but may vary.)

--
Ron Symonds - Microsoft MVP (FrontPage)
Reply only to group - emails will be deleted unread.

http://www.rxs-enterprises.org/fp

FrontPage Support: http://www.frontpagemvps.com/
 
M

Mick

Thomas and Ron, many thanks again, I try not to bother the group until I
really get stuck, and always have a go first. Also its never just a
copy/paste from the replies, your replies are always structured so I can also
learn from them. Thanks to all the MVP´s whose help is offered so freely.
Mick
 
Top