473,224 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,224 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 18288
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: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...

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.