We help IT Professionals succeed at work.

type mismatch with ubound...help!

ClassyLinks
ClassyLinks asked
on
Hi all....this page used to work on my NT server, but now getting errors on Win2000.

Type mismatch: 'ubound'

/classythemes.com2001/_aspstore/shopcart.asp, line 5


Here's the code....tia to anyone who can help!

<!--#INCLUDE FILE="adovbs.inc"-->
<%
  sCartItemNums = session("cartitemnumarray")
  nCartItemQtys = session("cartitemqtyarray")
  nNumCartItems = ubound(sCartItemNums)
 
  'Determine the mode of this page's operation. If we got here from a
  '  link that had a "mode" querystring of "add", mode is add:
  sMode = request.querystring("mode")
 
  'Or, we could have gotten here from a form:
  select case request.form("cmdSubmit")
    case "Proceed to Checkout"
      sMode = "checkout"
    case "Recalculate Order"  
      sMode = "recalc"
    case "Continue Shopping"
      sMode = "continue"
  end select
 
  if sMode = "add" then
    nThisItemIndex = 0
    sItemNo = ucase(request.querystring("itemno"))
    if nNumCartItems > 0 then
      for i = 1 to nNumCartItems
        if ucase(scartitemnums(i)) = sItemNo then
          nThisItemIndex = i
          exit for
        end if
      next
    end if
    if nThisItemIndex = 0 then
      nThisItemIndex = nNumCartItems + 1
      redim Preserve sCartItemNums(nThisItemIndex)
      redim Preserve nCartItemQtys(nThisItemIndex)
      sCartItemNums(nThisItemIndex) = sItemNo
      nCartItemQtys(nThisItemIndex) = 1
    else
      nCartItemQtys(nThisItemIndex) = nCartItemQtys(nThisItemIndex) + 1
    end if
    session("cartitemnumarray") = sCartItemNums
    session("cartitemqtyarray") = nCartItemQtys
    nNumCartItems = ubound(sCartItemNums)
  end if
 
  if sMode = "recalc" or sMode = "checkout" or sMode = "continue" then
    for i = 1 to nNumCartItems
      nThisQty = int(request.form("txtItemQty" & i))
      nCartItemQtys(i) = nThisQty
    next
    session("cartitemnumarray") = sCartItemNums
    session("cartitemqtyarray") = nCartItemQtys
  end if

  'Move to another page based on mode.
  '  If mode is "add" or "recalc", we stay here.
  '  If mode is "continue", we move back to the main page so the user
  '    can shop more.
  '  If mode is "checkout", we stay here but change the mode the
  select case sMode
    case "continue"
      response.redirect("../default.asp")
  end select
 
  set dbMain = server.createobject("ADODB.Connection")
  dbMain.ConnectionString="Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/classythemes.com2001/database/classythemesdb.mdb")&";"
  dbMain.open session("dblogin")

  if sMode = "checkout" then
    sPageHead = "ClassyThemes Checkout"
    sPageCaption = "Checkout"
  else
    sPageHead = "ClassyThemes Shopping Cart"
    sPageCaption = "Shopping Cart"
  end if
 
%>

<html>

<head>
<title><% =sPageHead%></title>
<link href="/classythemes.com2001/ClassyThemes.css" rel="stylesheet" type="text/css">
</head>

<body>
<!--#include file="../top.inc"-->
        <p align="center">
        <font color="#000000">
<% if sMode = "checkout" then%>
<form action="submitorder.asp" method="POST">    
<% else %>
<form action="shopcart.asp" method="POST">
<% end if %>
<%
  if nNumCartItems = 0 then
    response.write "There are no themes in your shopping cart.<br>"
  else
    if sMode = "checkout" then
%>
Your order is ready to submit. Please provide the following information
and click the "Submit Order" button.
<br>
<table align="center" border="0">
  <tr bgcolor="#c0c0c0">
    <th colspan="2" align="center"><font color="#000000">
      Customer Information</font>
  </tr>
  <tr>
<td colspan="2" align="center">Billing Details:</td>
  </tr>
  <tr>
<td>Title:</td>
<td><input type="text" name="bill_customer_title" size="3"> </td>
  </tr>
  <tr>
<td><font color="#FF0000">First Name:</font></td>
<td><input type="text" name="bill_first_name" size="40"> </td>
  </tr>
  <tr>
<td><font color="#FF0000">Last Name:</font></td>
<td><input type="text" name="bill_last_name" size="40"> </td>
  </tr>
  <tr>
<td>Company Name:</td>
<td><input type="text" name="bill_company" size="40"> </td>
  </tr>
  <tr>
<td>Street Address:</td>
<td><input type="text" name="bill_address_one" size="40"> </td>
  </tr>
  <tr>
<td></td>
<td><input type="text" name="bill_address_two" size="40"> </td>
  </tr>
  <tr>
<td>City:</td>
<td><input type="text" name="bill_city" size="40"> </td>
  </tr>
  <tr>
<td>State / Province:</td>
<td><input type="text" name="bill_state_or_province" size="40"> </td>
  </tr>
  <tr>
<td>Zip / Postal Code:</td>
<td><input type="text" name="bill_postal_code" size="40"> </td>
  </tr>
  <tr>
<td>Country:</td>
<td><select name="bill_country">
<option value="AF">AFGHANISTAN</option>
<option value="AL">ALBANIA</option>
<option value="DZ">ALGERIA</option>
<option value="INT">ALL_COUNTRIES_EXCEPT_THE_US</option>
<option value="AS">AMERICAN_SAMOA</option>
<option value="AD">ANDORRA</option>
<option value="AI">ANGUILLA</option>
<option value="AQ">ANTARCTICA</option>
<option value="AG">ANTIGUA_AND_BARBUDA</option>
<option value="AR">ARGENTINA</option>
<option value="AM">ARMENIA</option>
<option value="AW">ARUBA</option>
<option value="AU">AUSTRALIA</option>
<option value="AT">AUSTRIA</option>
<option value="AZ">AZERBAIJAN</option>
<option value="BS">BAHAMAS</option>
<option value="BH">BAHRAIN</option>
<option value="BD">BANGLADESH</option>
<option value="BB">BARBADOS</option>
<option value="BY">BELARUS</option>
<option value="BE">BELGIUM</option>
<option value="BZ">BELIZE</option>
<option value="BJ">BENIN</option>
<option value="BM">BERMUDA</option>
<option value="BT">BHUTAN</option>
<option value="BO">BOLIVIA</option>
<option value="BW">BOTSWANA</option>
<option value="BV">BOUVET_ISLANDS</option>
<option value="BR">BRAZIL</option>
<option value="IO">BRITISH_INDIAN_OCEAN_TERRITORY</option>
<option value="BN">BRUNEI</option>
<option value="BG">BULGARIA</option>
<option value="BF">BURKINA_FASO</option>
<option value="BI">BURUNDI</option>
<option value="CM">CAMBODIA</option>
<option value="CM">CAMEROON</option>
<option value="CA" selected>CANADA</option>
<option value="CV">CAPE_VERDE</option>
<option value="KY">CAYMAN_ISLANDS</option>
<option value="CF">CENTRAL_AFRICAN_REPUBLIC</option>
<option value="TD">CHAD</option>
<option value="CL">CHILE</option>
<option value="CN">CHINA</option>
<option value="CX">CHRISTMAS_ISLANDS</option>
<option value="CC">COCOS_KEELING_ISLANDS</option>
<option value="CO">COLOMBIA</option>
<option value="KM">COMOROS</option>
<option value="CG">CONGO</option>
<option value="CK">COOK_ISLAND</option>
<option value="CR">COSTA_RICA</option>
<option value="CI">COTE_DIVOIRE</option>
<option value="HR">CROATIA</option>
<option value="CY">CYPRUS</option>
<option value="CZ">CZECH_REPUBLIC</option>
<option value="DK">DENMARK</option>
<option value="DJ">DJIBOUTI</option>
<option value="DM">DOMINICA</option>
<option value="DO">DOMINICAN_REPUBLIC</option>
<option value="TP">EAST_TIMOR</option>
<option value="EG">EGYPT</option>
<option value="SV">EL_SALVADOR</option>
<option value="EC">EQUADOR</option>
<option value="GQ">EQUATORIAL_GUINEA</option>
<option value="ER">ERITREA</option>
<option value="EE">ESTONIA</option>
<option value="ET">ETHIOPIA</option>
<option value="FK">FALKLAND_ISLANDS</option>
<option value="FO">FAROE_ISLANDS</option>
<option value="FM">FEDERATED_STATES_OF_MICRONESIA</option>
<option value="FJ">FIJI</option>
<option value="FI">FINLAND</option>
<option value="FR">FRANCE</option>
<option value="GF">FRENCH_GUIANA</option>
<option value="PF">FRENCH_POLYNESIA</option>
<option value="TF">FRENCH_SOUTHERN_TERRITORIES</option>
<option value="GA">GABON</option>
<option value="GM">GAMBIA</option>
<option value="GE">GEORGIA</option>
<option value="DE">GERMANY</option>
<option value="GA">GHANA</option>
<option value="BI">GIBRALTAR</option>
<option value="GR">GREECE</option>
<option value="GL">GREENLAND</option>
<option value="GD">GRENADA</option>
<option value="GP">GUADELOUPE</option>
<option value="GU">GUAM</option>
<option value="GT">GUATEMALA</option>
<option value="GN">GUINEA</option>
<option value="GW">GUINEA_BISSAU</option>
<option value="GY">GUYANA</option>
<option value="HT">HAITI</option>
<option value="HM">HEARD_AND_MCDONALD_ISLANDS</option>
<option value="HN">HONDURAS</option>
<option value="HK">HONG_KONG</option>
<option value="HU">HUNGARY</option>
<option value="IS">ICELAND</option>
<option value="IN">INDIA</option>
<option value="ID">INDONESIA</option>
<option value="IE">IRELAND</option>
<option value="IL">ISRAEL</option>
<option value="IT">ITALY</option>
<option value="JM">JAMAICA</option>
<option value="JP">JAPAN</option>
<option value="JO">JORDAN</option>
<option value="KZ">KAZAKHSTAN</option>
<option value="KE">KENYA</option>
<option value="KI">KIRIBATI</option>
<option value="KW">KUWAIT</option>
<option value="KG">KYRGYZSTAN</option>
<option value="LA">LAOS</option>
<option value="LV">LATVIA</option>
<option value="LB">LEBANON</option>
<option value="LS">LESOTHO</option>
<option value="LR">LIBERIA</option>
<option value="LI">LIECHTENSTEIN</option>
<option value="LT">LITHUANIA</option>
<option value="LU">LUXEMBOURG</option>
<option value="MO">MACAU</option>
<option value="MG">MADAGASCAR</option>
<option value="MW">MALAWI</option>
<option value="MY">MALAYSIA</option>
<option value="MV">MALDIVES</option>
<option value="ML">MALI</option>
<option value="MT">MALTA</option>
<option value="MH">MARSHALL_ISLANDS</option>
<option value="MQ">MARTINIQUE</option>
<option value="MR">MAURITANIA</option>
<option value="MU">MAURITIUS</option>
<option value="YT">MAYOTTE</option>
<option value="FX">METROPOLITAN_FRANCE</option>
<option value="MX">MEXICO</option>
<option value="MD">MOLDOVA</option>
<option value="MC">MONACO</option>
<option value="MN">MONGOLIA</option>
<option value="MS">MONTSERRAT</option>
<option value="MA">MOROCCO</option>
<option value="MZ">MOZAMBIQUE</option>
<option value="MM">MYANMAR</option>
<option value="NA">NAMIBIA</option>
<option value="NR">NAURU</option>
<option value="NP">NEPAL</option>
<option value="NL">NETHERLANDS</option>
<option value="AN">NETHERLANDS_ANTILLES</option>
<option value="NC">NEW_CALEDONIA</option>
<option value="NZ">NEW_ZEALAND</option>
<option value="NI">NICARAGUA</option>
<option value="NE">NIGER</option>
<option value="NG">NIGERIA</option>
<option value="NU">NIUE</option>
<option value="NF">NORFOLK_ISLAND</option>
<option value="MP">NORTHERN_MARIANA_ISLANDS</option>
<option value="NO">NORWAY</option>
<option value="OM">OMAN</option>
<option value="PK">PAKISTAN</option>
<option value="PW">PALAU</option>
<option value="PA">PANAMA</option>
<option value="PG">PAPUA_NEW_GUINEA</option>
<option value="PY">PARAGUAY</option>
<option value="PE">PERU</option>
<option value="PH">PHILIPPINES</option>
<option value="PN">PITCAIRN</option>
<option value="PL">POLAND</option>
<option value="PT">PORTUGAL</option>
<option value="PR">PUERTO_RICO</option>
<option value="QA">QATAR</option>
<option value="KR">REPUBLIC_OF_KOREA</option>
<option value="MK">REPUBLIC_OF_MACEDONIA</option>
<option value="RE">REUNION</option>
<option value="RO">ROMANIA</option>
<option value="RU">RUSSIA</option>
<option value="WS">SAMOA</option>
<option value="SM">SAN_MARINO</option>
<option value="ST">SAO_TOME_AND_PRINCIPE</option>
<option value="SA">SAUDI_ARABIA</option>
<option value="SN">SENEGAL</option>
<option value="SC">SEYCHELLES</option>
<option value="SL">SIERRA_LEONE</option>
<option value="SG">SINGAPORE</option>
<option value="DK">SLOVAKIA</option>
<option value="SI">SLOVENIA</option>
<option value="SB">SOLOMON_ISLANDS</option>
<option value="SO">SOMALIA</option>
<option value="ZA">SOUTH_AFRICA</option>
<option value="ES">SPAIN</option>
<option value="LK">SRI_LANKA</option>
<option value="SH">ST_HELENA</option>
<option value="KN">ST_KITTS_AND_NEVIS</option>
<option value="LC">ST_LUCIA</option>
<option value="PM">ST_PIERRE_AND_MIQUELON</option>
<option value="VC">ST_VINCENT_AND_THE_GRENADINES</option>
<option value="SD">SUDAN</option>
<option value="SR">SURINAME</option>
<option value="SJ">SVALBARD_AND_JAN_MAYEN_ISLANDS</option>
<option value="SZ">SWAZILAND</option>
<option value="SE">SWEDEN</option>
<option value="CH">SWITZERLAND</option>
<option value="SY">SYRIA</option>
<option value="TW">TAIWAN</option>
<option value="TJ">TAJIKISTAN</option>
<option value="TZ">TANZANIA</option>
<option value="TH">THAILAND</option>
<option value="TG">TOGO</option>
<option value="TK">TOKELAU</option>
<option value="TO">TONGA</option>
<option value="TT">TRINIDAD_AND_TOBAGO</option>
<option value="TN">TUNISIA</option>
<option value="TR">TURKEY</option>
<option value="TM">TURKMENISTAN</option>
<option value="TC">TURKS_AND_CAICOS_ISLANDS</option>
<option value="TV">TUVALU</option>
<option value="UG">UGANDA</option>
<option value="UA">UKRAINE</option>
<option value="AE">UNITED_ARAB_EMIRATES</option>
<option value="GB">UNITED_KINGDOM</option>
<option value="US">UNITED_STATES</option>
<option value="UM">UNITED_STATES_MINOR_OUTLYING_ISLANDS</option>
<option value="UY">URUGUAY</option>
<option value="UZ">UZBEKISTAN</option>
<option value="VU">VANUATU</option>
<option value="VA">VATICAN_CITY</option>
<option value="VE">VENEZUELA</option>
<option value="VN">VIETNAM</option>
<option value="VG">VIRGIN_ISLANDS_BRITISH</option>
<option value="VI">VIRGIN_ISLANDS_USA</option>
<option value="WF">WALLIS_AND_FUTUNA_ISLANDS</option>
<option value="EH">WESTERN_SAHARA</option>
<option value="YE">YEMEN</option>
<option value="YU">YUGOSLAVIA</option>
<option value="ZR">ZAIRE</option>
<option value="ZM">ZAMBIA</option>
<option value="ZW">ZIMBABWE</option>
</select> </td>
  </tr>
  <tr>
<td>Phone #:</td>
<td><input type="text" name="bill_phone" size="40"> </td>
  </tr>
  <tr>
<td><font color="#FF0000">Email address:</font></td>
<td><input type="text" name="bill_email" size="40"> </td>
  </tr>
  <tr>
<td colspan="2">
  <hr>
</td>
  </tr>
  <tr>
<td colspan="2" align="center">Credit Card Details:</td>
  </tr>
  <tr>
<td>Credit Card Number:</td>
<td><input type="text" name="credit_card_number" size="20"> </td>
  </tr>
  <tr>
<td>Expiry Month:</td>
<td><select size="1" name="expire_month">
  <option selected>Expiry Date (Month)</option>
  <option value="01">January (01)</option>
  <option value="02">February (02)</option>
  <option value="03">March (03)</option>
  <option value="04">April (04)</option>
  <option value="05">May (05)</option>
  <option value="06">June (06)</option>
  <option value="07">July (07)</option>
  <option value="08">August (08)</option>
  <option value="09">September (09)</option>
  <option value="10">October (10)</option>
  <option value="11">November (11)</option>
  <option value="12">December (12)</option>
    </select> </td>
  </tr>
  <tr>
<td>Expiry Year:</td>
<td><select size="1" name="expire_year">
    <option selected>Expiry Date (Year)</option>
    <option value="2000">2000</option>
    <option value="2001">2001</option>
    <option value="2002">2002</option>
    <option value="2003">2003</option>
    <option value="2004">2004</option>
    <option value="2005">2005</option>
    <option value="2006">2006</option>
    <option value="2007">2007</option>
    <option value="2008">2008</option>
    <option value="2009">2009</option>
    <option value="2010">2010</option>
    </select></td>
  </tr>
  <tr>
<td colspan="2">
  <hr>
</td>
  </tr>
</table>
<font color="#000000">
<%
    else
      response.write "Your shopping cart currently contains these themes:"
    end if
%>
</font>
<table align="center" border="1" cellspacing="1" cellpadding="6">
  <tr>
    <td height="25">
      <p align="center"><font color="#000000">Quantity</font></p>
    </td>
    <td height="25">
      <p align="center"><font color="#000000">Item No.</font></p>
    </td>
    <td height="25">
      <p align="center"><font color="#000000">Item Name</font></p>
    </td>
    <td height="25">
      <p align="center"><font color="#000000">Price</font></p>
    </td>
    <td height="25">
      <p align="center"><font color="#000000">Extension</font></p>
    </td>
  </tr>
  <font color="#000000" size="-1">
  <%
  cSubTotal = 0
  nNumItems = 0
  for i = 1 to nNumCartItems
    Set rsProducts = Server.CreateObject("ADODB.Recordset")
    sSQL = "SELECT * FROM products WHERE itemproductnumber = '" & _
       sCartItemNums(i) & "'"
    rsProducts.open sSQL, dbMain, adopenstatic, _
      adlockpessimistic, adcmdtext%>
      <tr>
          <%
          sTemp = "<input type='Text' name='txtItemQty" & i & "' value='" & _
    nCartItemQtys(i) & "' size='3'>"
    %>
    <td align="center" height="22" valign="top"><font color="#000000"><% = sTemp %>
      </font></td>
    <td align="center" height="22" valign="top"><font color="#000000"><% = rsProducts("itemproductnumber") %>
      </font></td>
    <td height="22" valign="top" align="center"><font color="#FF0000"><% = rsProducts("itemname") %></font></td>
    <%
    if rsProducts("itemsaleprice") > 0 then
      cPrice = rsProducts("ItemSalePrice")
      else
      cPrice = rsProducts("ItemRegularPrice")
      end if
      %>
    <td align="center" height="22" valign="top"><font color="#000000"><% = cPrice%></font></td>
    <font color="#008000" size="-1">
    <%  
  cExtension = nCartItemQtys(i) * cPrice
  cSubTotal = cSubTotal + cExtension
    %>
    </font>
    <td align="center" height="22" valign="top"><font color="#000000">
      <p align="right"><% = formatcurrency(cExtension) %>
      </font></td>
  </tr><% next %>
  <font color="#008000" size="-1">
  </font>
  <tr>
    <td align="right" colspan="4" height="25"><font color="#000000">Subtotal</font></td>
    <td align="right" height="25"><font color="#000000"><% = formatcurrency(cSubTotal) %>
      </font></td>
  </tr>
  <font color="#008000" size="-1"><% cShipping = 0.00 + (0.00 * nNumItems) %>
  </font>
  <tr>
    <td align="right" colspan="4" height="25"><font color="#000000">Shipping
      &amp; Handling</font></td>
    <td align="right" height="25"><font color="#000000"><% = formatcurrency(cShipping) %>
      </font></td>
  </tr>
  <font color="#008000" size="-1"><% cTotal = cSubTotal + cShipping %>
  </font>
  <tr>
    <td align="right" colspan="4" height="25"><font color="#000000">Grand Total</font></td>
    <td align="right" height="25"><font color="#000000"><img src="images/canada2.gif" alt="Canadian $" align="absmiddle" border="0">&nbsp;&nbsp;
      <input type="hidden" value="<%=formatcurrency(cTotal)%>" name="charge_total"><% = formatcurrency(cTotal) %>
      </font></td>
  </tr>
  </table>
</font>
  </center>
<font color="#000000" size="-1">
  <center>
<hr>
&nbsp;<table border="1" width="100%">
  <tr>
    <td width="100%">
      <p align="center">
<font color="#000000">
If you would like to convert this amount of Canadian Dollars to your
currency to see the approximate charge to your credit card, <a href="samp-ucc.asp?convertamount=<% = (cTotal) %>" target="_blank">click
here.</a></font></td>
  </tr>
</table>
<div align="center">

<hr>

<font color="#008000">

<input type="Submit" name="cmdSubmit" value="Continue Shopping">
<input type="Submit" name="cmdSubmit" value="Recalculate Order">
<br><br>
<% if sMode = "checkout" then %>
<input type="Submit" name="cmdSubmit" value="Submit Order">
<% else %>
<input type="Submit" name="cmdSubmit" value="Proceed to Checkout"><br>
</font>
<font color="#000000">
<% end if %>
</font>
</div></form>
<font  color="#008000" size="-1">
<% end if %>
        </font>
      </center>
      </font>
      </font>
<!--#include file="../bottom.inc"-->
</body>

</html>
Comment
Watch Question

"Type Mismatch" means exactly that...there is a mismatch in the type of variable being expected in the call to UBound.  UBound() expects an array as a parameter, so the error means he is not getting an array.  Ensure that the variable 'sCartItemNums' is indeed an array.  If it is just a comma-delimited string, you can do something like:

nNumCartItems = Ubound(Split(sCartItemNums, ","))

Author

Commented:
Thanks Azra....How can I tell what sCartItemNums is pulling?  Your fix works for that line, but then I get other errors that need that variable too.

Author

Commented:
Ok...I think the problem is that it is not pulling the session variables.
My global.asa is in the root, how do I ensure it is getting those values????

Commented:

Commented:
I have had problems reading info from the global.asa when the virtual directory has not been set up as an application.

In IIS manager, right click on your VDIR, select properties.  In this screen, click the "Create" button on the "application" tab.  

Hope this helps.

DG

Author

Commented:
Thanks for the suggestion d_glenn, but it was already set up as an app.

Thanks for the link dgorin...I'll read through it and see if I can plug my way around.
Well, if you can get away with leaving that variable as a string, you may want to work your other code around to use it that way instead (often times gives less headaches than working with arrays anways).  Also, with the command delimited string, you can then make it an array any time you really need to, such as processing the entries in a loop, using the split function:

Dim vArr

vArr = Split(strCommaDelimited, ",")

For i = 0 To UBound(vArr)
   ...
Next

Explore More ContentExplore courses, solutions, and other research materials related to this topic.