473,322 Members | 1,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

formatnumber function returns error

The following code with formatnumber function returns me the following
code. Why? Thanks.
<td align="right"><Font
class=content4><%=formatNumber(ars.Fields("SOLD_AM OUNT"),2)%></td>

Microsoft VBScript runtime error '800a000d'

Type mismatch: 'formatNumber'
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #1
11 18294
Are you sure SOLD_AMOUNT is a number and it not null?

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


"eddie wang" <ew***@kmg.com> wrote in message
news:uw**************@TK2MSFTNGP11.phx.gbl...
The following code with formatnumber function returns me the following
code. Why? Thanks.
<td align="right"><Font
class=content4><%=formatNumber(ars.Fields("SOLD_AM OUNT"),2)%></td>

Microsoft VBScript runtime error '800a000d'

Type mismatch: 'formatNumber'
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 19 '05 #2
eddie wang wrote on 11 feb 2004 in microsoft.public.inetserver.asp.general:
<%=formatNumber(ars.Fields("SOLD_AMOUNT"),2)%>

Microsoft VBScript runtime error '800a000d'

Type mismatch: 'formatNumber'


Make sure ars.Fields("SOLD_AMOUNT") is always a number

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #3
There is null value. IS there anyway to use formatnumber and other
functions to say if there is null then not to use formatnumber, else use
formatnumber??

Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #4
eddie wang wrote:
There is null value. IS there anyway to use formatnumber and other
functions to say if there is null then not to use formatnumber, else
use formatnumber??

Thanks.


Create a NullToZero function:

function NullToZero(pData)
if len(pData) = 0 then
NullToZero = cdbl(0)
else
on error resume next
pData = cdbl(pData)
if not IsNumeric(pData) then pData = 0
NullToZero = cdbl(pData)
end if
end function

Then use the function in your call to FormatNumber:
<%=formatNumber(NullToZero(ars.Fields("SOLD_AMOUNT ")),2)%>

HTH.
Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #5
Why is there a NULL value? Why are you displaying a NULL value? Why are
you pulling a NULL value from your database? Can you not make the query
return 0 if it's NULL, or does that have a different meaning?

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


"eddie wang" <ew***@kmg.com> wrote in message
news:uD**************@TK2MSFTNGP11.phx.gbl...
There is null value. IS there anyway to use formatnumber and other
functions to say if there is null then not to use formatnumber, else use
formatnumber??

Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 19 '05 #6
0 means there is a value of 0. Null means there is no value. There is
difference between 0 and null.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #7
eddie wang wrote:
0 means there is a value of 0. Null means there is no value. There
is difference between 0 and null.

You cannot use FormatNumber on an empty string or a Null value. If you do
not want to display anything when the field contains a Null, then you will
need to use some logic to determine whether the value is written to the
response or not:
<%=
if len(ars.Fields("SOLD_AMOUNT")) > 0 then
formatNumber(ars.Fields("SOLD_AMOUNT"),2)
end if
%>

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #8
> 0 means there is a value of 0. Null means there is no value. There is
difference between 0 and null.


Thanks, I understand the difference between 0 and NULL. I was asking if it
matters for YOUR scenario (often it doesn't, and NULLs weren't meant to be
allowed in the database).

If you need to differentiate between 0 and NULL, then you will need to check
somehow, either by including a flag in the query or checking the actual
value as Bob showed.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
Jul 19 '05 #9
This NullToZero function will replace all the null values to 0. Is
there a way to display all the null values as they are and to display
the rest with two decimals? Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #10
> This NullToZero function will replace all the null values to 0. Is
there a way to display all the null values as they are and to display
the rest with two decimals? Thanks.


What does "as they are" mean? Do you want the word NULL to be written to
the screen, or do you want an empty space, or do you want "n/a", or do you
want "I don't know why I have NULLs here", or do you want something else?

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
Jul 19 '05 #11
eddie wang wrote:
This NullToZero function will replace all the null values to 0. Is
there a way to display all the null values as they are and to display
the rest with two decimals? Thanks.


I think I answered this in my other post.

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: varois83 | last post by:
Hi I am a newbie and struggling with my guestbook validation process. I have found the following function online to check the length of a form field. <?php function checkLength($string,...
6
by: Owen | last post by:
Hi, can somebody help me please... I'm trying to set up a very simple asp page that sends me an email when it runs. This is just to try and get CDOSYS working so I can send out emails from my...
4
by: octavio | last post by:
Hello members of the comp.lang.c newsgroup. Please I need you help on the following one. Compiling the simple code I'm getting this error message. Why ? Please what's the correct type of the fb...
18
by: ben.carbery | last post by:
Hi, I have just written a simple program to get me started in C that calculates the number of days since your birthdate. One thing that confuses me about the program (even though it works) is...
4
by: Michael Yanowitz | last post by:
I am still new to Python but have used it for the last 2+ months. One thing I'm still not used to is that functions parameters can't change as expected. For example in C, I can have status =...
5
by: Travis | last post by:
I am using a function that returns a const char * that is usually a word, etc. How can I check to see if what it returns is empty? I tried if (function() == "") and (function() == NULL) and...
1
TheMan1
by: TheMan1 | last post by:
Hi, I'm making a simple program in C++. I have an object named TextReader, with a function GetString(), and I also have another object, TextWriter. Now when *TextWriter is called, it needs to...
2
by: davidj411 | last post by:
if you run execfile function to run a python script and that script has variables and functions, should't those variable change in the interactive prompt too? script snippet that calls the...
3
by: Ananthu | last post by:
Hi, I use BulkSMSGateway - ATSMS.dll for sending SMS from ASP.NET. When I click Connect button, I am able to connect to the mobile using bluetooth successfully from my WebPage. But when i...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.