|
 |
asp_web_howto thread: Formatting a Number
Message #1 by "Lucy Robinson" <lucy@v...> on Tue, 26 Nov 2002 16:11:37
|
|
Please can someone help me with the following - i'm sure it's really easy
to do but i can't seem to do it !!
I've got a value that i'm showing on-screen as follows:
Response.Write (rs_GBLDA.Fields.Item("DAWinTotal").Value)
on screen value: 15000
If i put formatnumber around it i get the following:
Response.Write formatnumber(rs_GBLDA.Fields.Item("DAWinTotal").Value)
on screen value: 15,000.00
What i want to see is this on-screen: 15,000
How can i get rid of the last three elements of the string i.e. the .00
bit? I have a few values like this but it will always be taking 3 from the
right and displaying the rest.
Thanks in advance - this has been puzzling me for a while now.
Lucy
Message #2 by "phil griffiths" <pgtips@m...> on Tue, 26 Nov 2002 16:21:28
|
|
There are other parameters you can supply to the FormatNumber function,
e.g. FormatNumber(15000, 0) specifies 0 digits after the decimal point, so
this gives you what you want.
hth
Phil
>-------------------------------------------------
> Please can someone help me with the following - i'm sure it's really
easy
t> o do but i can't seem to do it !!
> I've got a value that i'm showing on-screen as follows:
> Response.Write (rs_GBLDA.Fields.Item("DAWinTotal").Value)
> on screen value: 15000
> If i put formatnumber around it i get the following:
> Response.Write formatnumber(rs_GBLDA.Fields.Item("DAWinTotal").Value)
> on screen value: 15,000.00
> What i want to see is this on-screen: 15,000
> How can i get rid of the last three elements of the string i.e. the .00
b> it? I have a few values like this but it will always be taking 3 from
the
r> ight and displaying the rest.
> Thanks in advance - this has been puzzling me for a while now.
> Lucy
Message #3 by John Chapman <johnc@w...> on Tue, 26 Nov 2002 16:09:47 -0000
|
|
You can tell formatnumber that you don't want to display decimal points by
doing:
Response.Write(FormatNumber(mynum,0))
The 0 declares you want to display 0 figures after the decimal point.
John
John Richard Chapman
Chief Technical Editor
ASPToday
Wrox Press Ltd.
john@a...
http://www.asptoday.com/
http://www.csharptoday.com/
-----Original Message-----
From: Lucy Robinson [mailto:lucy@v...]
Sent: 26 November 2002 16:12
To: ASP Web HowTo
Subject: [asp_web_howto] Formatting a Number
Please can someone help me with the following - i'm sure it's really easy
to do but i can't seem to do it !!
I've got a value that i'm showing on-screen as follows:
Response.Write (rs_GBLDA.Fields.Item("DAWinTotal").Value)
on screen value: 15000
If i put formatnumber around it i get the following:
Response.Write formatnumber(rs_GBLDA.Fields.Item("DAWinTotal").Value)
on screen value: 15,000.00
What i want to see is this on-screen: 15,000
How can i get rid of the last three elements of the string i.e. the .00
bit? I have a few values like this but it will always be taking 3 from the
right and displaying the rest.
Thanks in advance - this has been puzzling me for a while now.
Lucy
Message #4 by "Craig Flannigan" <ckf@k...> on Tue, 26 Nov 2002 16:16:26 -0000
|
|
Two ways...
= Round(formatnumber(rs_GBLDA.Fields.Item("DAWinTotal").Value),2)
Or..
Left(formatnumber(rs_GBLDA.Fields.Item("DAWinTotal").Value),len(formatnumber
(rs_GBLDA.Fields.Item("DAWinTotal").Value))-3)
I think they should work!
Craig.
-----Original Message-----
From: Lucy Robinson [mailto:lucy@v...]
Sent: 26 November 2002 16:12
To: ASP Web HowTo
Subject: [asp_web_howto] Formatting a Number
Please can someone help me with the following - i'm sure it's really easy
to do but i can't seem to do it !!
I've got a value that i'm showing on-screen as follows:
Response.Write (rs_GBLDA.Fields.Item("DAWinTotal").Value)
on screen value: 15000
If i put formatnumber around it i get the following:
Response.Write formatnumber(rs_GBLDA.Fields.Item("DAWinTotal").Value)
on screen value: 15,000.00
What i want to see is this on-screen: 15,000
How can i get rid of the last three elements of the string i.e. the .00
bit? I have a few values like this but it will always be taking 3 from the
right and displaying the rest.
Thanks in advance - this has been puzzling me for a while now.
Lucy
_____________________________________________________________________
Please contact I.T. Support if you have received this email in error.
This e-mail has been scanned for all viruses by Star Internet.
_____________________________________________________________________
_____________________________________________________________________
Kingfield Heath Ltd. Email Disclaimer
Confidentiality : This email and its attachments are intended for the
above-named only and may be confidential. If they have come to you in
error you must take no action based on them, nor must you copy or
show them to anyone; please reply to this email and highlight the
error.
Security Warning : Please note that this email has been created in
the knowledge that the internet is not a 100% secure communications
medium. We advise that you understand and observe this lack of
security when emailing us.
Viruses : Although we have taken steps to ensure that this email and
attachments are free from any virus, we advise that, in keeping with
good computing practice, the recipient should ensure they are
actually virus free.
_____________________________________________________________________
Message #5 by "Lucy Robinson" <lucy@v...> on Wed, 27 Nov 2002 16:29:11
|
|
Thanks Phil - it all works fine now :)
Didn't know that you could put ,0 at the end - I was trying everything
else but that one !!
|
|
 |