Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 28th, 2007, 08:51 PM
Registered User
 
Join Date: Feb 2007
Location: elk grove, ca, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Calculation using if...then...else statement

Hi,

I'm Trying to find out if ASP calculation can be used with if...then...else statement. Did few changes but when trying to open the file it would not let me. Trying to do is these "if (T) > (S-T) then (T) else (S-T)". T = transportation & S = shipping charge. I do not have experienced of this but I want to learn more as I go along with it.

Current Cart Value: $9.00
Shipping Charge: $
Total: $
Shipping Method Transportation Shipping Charge
UPS Ground USA $5.00 $5.81
UPS 3 Day Select $10.00 $11.62
UPS 2nd Day Air $25.00 $28.24
UPS 2nd Day Air AM $25.00 $28.24
UPS Next Day Air $55.00 $59.68


<html>
    <head>
        <Title><%=sWebSiteName%> - Shipping Calculator</title>





    </head>
    <body class="siteNav3TD">
        Shipping Calculator
        <table width="450" cellspacing="5" cellpadding="0" border="0">
            <tr>
                <td width="425">
                    <form name="frmShip" method="post" action="<%=sNonSecurePath%>shipcalculator.asp?Cart Id=<%=sCartId%>" onSubmit="return ZipCode_validate('<%=bUseDestZone%>');">
                        <table width=425>
                            <tr>
                                <td width=125> Zipcode: </td>
                                <td width=300><input tabindex="1" type="text" size="15" maxlength="15" name="zipcode" value="<%=sZipCode%>" Class="Content"></td>
                            </tr>
                            <%If bUseDestZone Then%>
                                <tr>
                                    <td width=125> City: </td>
                                    <td width=300><input tabindex="2" type="text" size="15" maxlength="40" name="City" value="<%=sCity%>" Class="Content">(Only for United States)</td>
                                </tr>
                                <tr>
                                    <td width=125> State: </td>
                                    <td width=300><input tabindex="3" type="text" size="15" maxlength="25" name="State" value="<%=sState%>" Class="Content">(Only for United States)</td>
                                </tr>
                                <%If Not rsCountries.Eof Then%>
                                <tr>
                                    <td width=125>Country:</td>
                                    <td width=300>

                                        <select name="COUNTRY" size="1" tabindex="4" Class="Content"><%
                                            Do While Not rsCountries.Eof
                                                If rsCountries("COUNTRY_NAME") = sCountry Then
                                                    Response.Write "<option value='" & rsCountries("COUNTRY_NAME") & "' selected>" & rsCountries("COUNTRY_NAME") & "</option>"
                                                Elseif rsCountries("COUNTRY_NAME")="UNITED STATES" And sCountry="" Then
                                                    Response.Write "<option value='" & rsCountries("COUNTRY_NAME") & "' selected>" & rsCountries("COUNTRY_NAME") & "</option>"
                                                Else
                                                    Response.Write "<option value='" & rsCountries("COUNTRY_NAME") & "'>" & rsCountries("COUNTRY_NAME") & "</option>"
                                                End if
                                                rsCountries.Movenext
                                            Loop%>
                                        </select>

                                    </td>
                                </tr>
                                <%End if
                            End if%>
                            <tr>
                                 <td width=125 >Address type:</td>
                                 <td>

                                    <select name="RESI" tabindex="5" Class="Content">
                                         <option value = "0">Please select address type</option>
                                         <option value = "F" <%If sAddressinfo = "F" Then%>selected<%End If%>>Business</option>
                                         <option value = "T" <%If sAddressinfo = "T" Then%>selected<%End If%>>Residential</option>
                                    </select>

                                 </td>
                            </tr>
                            <%If objShoppingCart.IsCODEnabled(sConnectionString,sCa rtId) Then%>
                                <tr>
                                 <td width=125 >COD Fee:</td>
                                 <td><INPUT type="checkbox" name="ISCOD" tabindex="6" <% If bIsCOD Then %> checked <%End if%>>
                                 </td>
                                </tr>
                            <%End if%>
                            <tr><td>Â </td><td> <a tabindex="7" href="#" onClick="ZipCode_validate('<%=bUseDestZone%>');ret urn false;"> <img src="images/go.gif" border="0"></a></td></tr>
                        </table>
                        <br>To calculate your shipping charge, enter the ZipCode. Then, select the carrier of your choice.
                    </form>
                </td>
            </tr>
        </table>

        <%If (Trim(sCountry) <> "" OR Trim(sZipcode) <> "") Then
            If Not rsDeliveryMethod.Eof Then
                If rsDeliveryMethod("AMOUNT") > 0 OR rsDeliveryMethod("FREE_SHIPPING") = "T" Then
                    If sZipCode = "" Then%>
                        <br>
                            <b>Shipping methods available for the country "<%=Trim(sCountry)%>".</b>
                        <br>
                    <%Else%>
                        <br>
                            <b>Shipping methods available for the zipcode "<%=Trim(sZipCode)%>".</b>
                    <%End if%>

                    <form name="frmCost">
                        <table border="0" cellspacing="0" width="600" cellpadding="5">
                            <tr>
                                <td colspan="4">
                                    <table border="0" cellspacing="0" width="450" cellpadding="5">
                                        <tr>
                                            <td>Current Cart Value: </td>
                                            <td><%= sCurrSymbol & Formatnumber(sCartTotal,2)%><%If bAddCurrExists Then%> (<%=sAdditionalCurrencySymbol%><%=Formatnumber(sCa rtTotalInAddCurr,2)%>)<%End If%></td>
                                        </tr>
                                        <tr>
                                            <td>Shipping Charge:</td>
                                            <td><%=sCurrSymbol%><input type="text" name="shipprice" value=<%=FormatNumber(rsDeliveryMethod("AMOUNT"),2 )%> size="10" readonly onfocus = "this.blur()" class=content><%If bAddCurrExists Then%> <%=sAdditionalCurrencySymbol%>Â Â <input type="text" name="shipprice_add_curr" value=<%=FormatNumber(rsDeliveryMethod("ADD_CURR_A MOUNT"),2)%> size="10" readonly onfocus = "this.blur()" class=content><%End If%></td>
                                        </tr>
                                        <tr>
                                            <td>Total:</td>
                                            <td><%=sCurrSymbol%><input type="text" name="total" size="10" value=<%=FormatNumber((cdbl(rsDeliveryMethod("AMOU NT"))) * (cdbl(sCartTotal),2))%> readonly onfocus = "this.blur()" class=content><%If bAddCurrExists Then%> <%=sAdditionalCurrencySymbol%>Â Â <input type="text" name="total_add_curr" size="10" value=<%=FormatNumber((cdbl(rsDeliveryMethod("ADD_ CURR_AMOUNT")) * cdbl(sCartTotalInAddCurr)),2)%> readonly onfocus = "this.blur()" class=content><%End If%></td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td>Shipping Method</td>
                                <td>Transportation</td>
                                <%If bIsCOD Then%>
                                <td><span class="ContboldRd">COD Fee</span></span></td>
                                <%End if%>
                                <td>Shipping Charge</td>
                            </tr>
                            <%iIndex = 1
                            Do While Not rsDeliveryMethod.Eof%>
                                <tr>
                                    <td>
                                        <input type="radio" name="radsel" value="<%=FormatNumber(rsDeliveryMethod("AMOUNT"), 2,,,0)%>*<%=FormatNumber(rsDeliveryMethod("ADD_CUR R_AMOUNT"),2,,,0)%>" <%If iIndex=1 Then%>Checked<%End If %> onClick="ShipCharge_Calculate(<%=Application("loca le")%>);">
                                        <%=rsDeliveryMethod("Deliv_DESC")%></td>
                                    <td><span class="Contsmall"><%=sCurrSymbol & FormatNumber(rsDeliverymethod ("TRANSPORTATION"))%><%If bAddCurrExists Then%> (<%=sAdditionalCurrencySymbol & FormatNumber(rsDeliverymethod("ADD_CURR_TRANSPORTA TION"),2)%>)<%end if%></span></td>
                                    <%If bIsCOD Then%>
                                        <td><span class="Contsmall"><%=sCurrSymbol & FormatNumber(rsDeliverymethod ("CODFEE"))%><%If bAddCurrExists Then%> (<%=sAdditionalCurrencySymbol & FormatNumber(rsDeliverymethod("ADD_CURR_CODFEE"),2 )%>)<%end if%></span></td>
                                    <%End if%>
                                    <td><%=sCurrSymbol & FormatNumber(rsDeliveryMethod("AMOUNT"),2)%> <%If bAddCurr < bAddCurr-(rsDeliveryMethod("AMOUNT"),2) Then%> (<%=sAdditionalCurrencySymbol & FormatNumber(rsDeliverymethod("ADD_CURR_AMOUNT"),2 )%>)<% ELSE (bAddCurr-(rsDeliveryMethod("AMOUNT"),2)) = sAdditionalCurrencySymbol & FormatNumber(rsDeliverymethod("ADD_CURR_AMOUNT"),2 )%> <%end if%></td>
                                </tr>
                                <%rsDeliveryMethod.MoveNext
                                iIndex = iIndex + 1
                            Loop%>
                            <tr><td colspan="4">Note: The charges listed are estimates. Actual shipping charges will be calculated during the checkout process.</td></tr>
                        </table>
                    <Script language=javascript >
                        ShipCharge_Calculate(<%=Application("locale")%>)
                    </script>
                <%Else%>
                    No shipping method is available for the selected criteria.
                <%End If
            Else%>
                No shipping method is available for the selected criteria.
            <%End If
        End If%>
        </form>
        <br><br>
        <a href="#" onClick="window.close();return false;"><img src="images/close.gif" border="0" tabindex="8" alt="Close"></a>
    </BODY>

    <script language="javascript">
        setTitleForImages();
        if((navigator.userAgent.toUpperCase().indexOf("MAC ") != -1) && (navigator.userAgent.toUpperCase().indexOf("GECKO" ) == -1))
        {
            setHrefForLinks();
        }
    </script>
</HTML>


  #2 (permalink)  
Old February 28th, 2007, 09:07 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

This is the wrong forum, you should be posting in the classic forum. Likewise posting that much code isn't bound to get you much help as none of use are going to copy it, paste it, and see what happens. Paste your problemmatic code that is pertienent to your question.

To answer your question though, if you do something like

If (2 + 3) < (2 + 4) then

End if

Yes that will work.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
  #3 (permalink)  
Old March 7th, 2007, 07:29 PM
Authorized User
 
Join Date: Mar 2007
Location: , , .
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

if (T) > (S-T) then (T) else (S-T)".
T = transportation & S = shipping charge.

sub doIt()
  dim myReturnValue as integer
  myReturnValue = getHigher(shippingCost,Transportation)
end sub

private function getHigher(s as integer,t as integer) as integer
  if t > (s - t) then
     return t
  else
     return s - t
  end if
end function



 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculation dillemma.... cuzintone SQL Language 0 April 7th, 2005 03:59 PM
Calculation Grantm Access 3 February 16th, 2004 10:14 AM
Calculation in Report lryckman Access 2 February 10th, 2004 08:44 AM
Skewness calculation in SQL statement akmhasan Oracle 0 July 13th, 2003 04:27 AM



All times are GMT -4. The time now is 05:31 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.