Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old December 28th, 2005, 11:23 AM
Authorized User
Points: 292, Level: 5
Points: 292, Level: 5 Points: 292, Level: 5 Points: 292, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2005
Location: , , .
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default Math functions-Please help!



I have a variable coming through an XML string into my .asp page (payamt). I need to send this through to be processed, but...I also need to create a NEW field called "totalamount". The totalamount should be equal to the payamt * 3%. I've tried making sure that the fields are set as Integers, but I keep getting a "Type Mismatch" error. I have a looming deadline...please help!

        Set objpayamt = xmlDoc.getElementsByTagName("payamt")
    varpayamt = objpayamt.item(0).text
    Dim convfee
    Dim payamt
    Dim totalamount
    Set payamt = CInt("varpayamount")
    Set totalamount = ("payamt" * .03)
  #2 (permalink)  
Old December 28th, 2005, 11:34 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Is this related to ASP.NET 2.0??? If not, you're better off posting these kind of questions in one of the Classic ASP forums, accessible by clicking View All Forums on the left.

That said, take a look at this:

Set totalamount = ("payamt" * .03)

You try to multiple the *string* "payamt" by .03. Drop the quotes and it should work.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #3 (permalink)  
Old December 28th, 2005, 11:42 AM
Authorized User
Points: 292, Level: 5
Points: 292, Level: 5 Points: 292, Level: 5 Points: 292, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2005
Location: , , .
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar,

Thanks for the quick reply. I dropped the " ", but this is the error I'm still getting.
  Also, sorry if I mis-posted, wasn't sure exactly which forum to use.

    Microsoft VBScript runtime error '800a000d'

    Type mismatch: 'CInt'


  #4 (permalink)  
Old December 28th, 2005, 11:46 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Then try this:

Response.Write(objpayamt.item(0).text)
Response.End

What does it write to the screen?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #5 (permalink)  
Old December 28th, 2005, 12:06 PM
Authorized User
Points: 292, Level: 5
Points: 292, Level: 5 Points: 292, Level: 5 Points: 292, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2005
Location: , , .
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Am getting this now:

Microsoft VBScript runtime error '800a01a8'

Object required: 'varpayamt'

/new/upshurCodej2.ASP, line 132

Here's the re-written code:
    Set objpayamt = xmlDoc.getElementsByTagName("payamount")
    varpayamt = objpayamt.item(0).text
Response.Write(varpayamt.item(0).text)
Response.End


  #6 (permalink)  
Old December 28th, 2005, 12:21 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
quote:Originally posted by Imar
 Then try this:

Response.Write(objpayamt.item(0).text)
Response.End
You used varpayamt.item(0).text instead of objpayamt.item(0).text

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.


Similar Threads
Thread Thread Starter Forum Replies Last Post
Math Functions on dynamic data jroxit Classic ASP Basics 3 January 23rd, 2007 12:07 PM
Getting percentages with math functions tslag XSLT 1 June 22nd, 2006 11:47 AM
Math Namespace transtar C# 3 February 12th, 2006 09:50 AM
Graphics Math Functions vb certified Pro VB.NET 2002/2003 2 January 1st, 2006 11:06 AM
Why are my math functions not being included? jkeen BOOK Beginning Linux Programming, 3rd Edition 4 October 22nd, 2004 05:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.