Welcome to Dream.In.Code
Become an Expert!

Join 150,064 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,770 people online right now. Registration is fast and FREE... Join Now!




ASP HELP

 
Reply to this topicStart new topic

ASP HELP

MarineDrillInstructor29
22 Feb, 2008 - 01:41 AM
Post #1

New D.I.C Head
*

Joined: 7 Dec, 2007
Posts: 17


My Contributions
Good Morning,
I'm having a small problem. I'm supposed to create a web page that calculates an arithmetic expression using server-side script. When I run the script I get an error. I'm using IIS to run this script and the error I get is a mismatch error. Here is the code. Thanks.

CODE

<% @language="vbscript" %>
<%
const bkName="Chancy's Bookstore"
const bkEmail="info@chancybooks.com"
dim bk1, bk2, bk3, total, today
bk1="$1.99"
bk2="$2.99"
bk3="$3.99"
total= bk1 + bk2 + bk3
today=WeekdayName(Weekday(Date)) & "," & _
MonthName(Month(Date)) & " " & _
Day(Date) & ", " & Year(Now()) %>
<html><head><title>Shopping Cart</title></head>
<body bgColor="#CCCCFF">
<font color="#000080"</font>
<div align="center">
<h2><% = bkName %></h2>
<h3><% = bkEmail %></h3>
<h3>Your Shopping Cart</h3>
You purchased your products on <br><br>
<% response.write WeekdayName(Weekday(Date)) & ", " & _
    MonthName(Month(Date)) & " " & _
    Day(Date) & ", " & Year(Now()) %><br><br>
<% if Total <> 0 then %>
   <table align ="center" width="150">
   <tr><td>Book 1 </td><td align="right">
   <% = formatCurrency(bk1) %>
   </td></tr>
   <tr><td>Book 2</td><td align="right">
   <% = formatCurrency(bk2) %>
   </td></tr>
   <tr><td>Book 3</td><td align="right">
   <% = formatCurrency(bk3) %>
   </td></tr>
   <tr><td> Total </td><td align="right">
   <% = formatCurrency(total) %>
   </td></tr>
<% else %>
    You have nothing in your shopping cart!
<% end if %>
</body></html>


User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: ASP HELP
23 Feb, 2008 - 09:43 PM
Post #2

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
The following code is going to give a type mismatch error because you're trying to add strings, which cannot be done


vb

dim bk1, bk2, bk3, total, today
bk1="$1.99"
bk2="$2.99"
bk3="$3.99"
total= bk1 + bk2 + bk3



You're going to need Double or Decimal data types for this, not string


vb

dim bk1, bk2, bk3 As Double
Dim total, today
bk1= 1.99
bk2= 2.99
bk3= 3.99
total= bk1 + bk2 + bk3


Thats the path you're going to have to take, you cant perform mathematical operations on strings. Hope that helps a little smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 10:47PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month