Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: R: Format


Message #1 by "Giovanni Salucci" <g.salucci@n...> on Wed, 20 Feb 2002 11:00:34 +0100

as posted some time ago from ken (?)

here:



add this function  to your page



function convert(a)

    convert = string(4 -len(a) , "0") + cstr(a)

end function





and then usage is



b = convert(4)

Response.Write b





Giovanni







-----Messaggio originale-----

Da: Andy@a... [mailto:Andy@a...]

Inviato: mercoledì 20 febbraio 2002 9.42

A: ASP Web HowTo

Oggetto: [asp_web_howto] Format





Hi



I have a number returned from a datsbase and I have to display it on a

page with leading zeros. IE if 4 is returned I have to display 0004.



I get type mismatch errors if I use format() and I can't get the leading

zeros with FormatNumber().



I need to do this with ASP because I have to send an email receipt of the

number in the correct format.



Any clues?



Andy Green




$subst('Email.Unsub').



Message #2 by Oleg Kapeljushnik <c-oleg.kapeljushnik@w...> on Wed, 20 Feb 2002 09:32:33 -0500
Another way to do it is :



Number =3D Right("0000" & Number)



Oleg.



-----Original Message-----

=46rom: Giovanni Salucci [mailto:g.salucci@n...]

Sent: February 20, 2002 5:01 AM

To: ASP Web HowTo

Subject: [asp_web_howto] R: Format







as posted some time ago from ken (?)

here:



add this function  to your page



function convert(a)

    convert =3D string(4 -len(a) , "0") + cstr(a)

end function





and then usage is



b =3D convert(4)

Response.Write b





Giovanni







-----Messaggio originale-----

Da: Andy@a... [mailto:Andy@a...]

Inviato: mercoled=EC 20 febbraio 2002 9.42

A: ASP Web HowTo

Oggetto: [asp_web_howto] Format





Hi



I have a number returned from a datsbase and I have to display it on 

a

page with leading zeros. IE if 4 is returned I have to display 0004.



I get type mismatch errors if I use format() and I can't get the lead

ing

zeros with FormatNumber().



I need to do this with ASP because I have to send an email receipt of

 the

number in the correct format.



Any clues?



Andy Green




$subst('Email.Unsub').








$subst('Email.Unsub').





Message #3 by "Spam Free" <spam.free@n...> on Thu, 21 Feb 2002 15:46:42 -0000
Hi,



I want to go the other way and round a number 2 decimal places



e.g. make 411.25764646 display as 411.26 to places...



ASP doesn't seem to like the format method I use in VB

format (number, "0.00")





Regards

spam.free@n...



----- Original Message -----

From: "Oleg Kapeljushnik" <c-oleg.kapeljushnik@w...>

To: "ASP Web HowTo" <asp_web_howto@p...>

Sent: Wednesday, February 20, 2002 2:32 PM

Subject: [asp_web_howto] RE: R: Format





Another way to do it is :



Number = Right("0000" & Number)



Oleg.



-----Original Message-----

From: Giovanni Salucci [mailto:g.salucci@n...]

Sent: February 20, 2002 5:01 AM

To: ASP Web HowTo

Subject: [asp_web_howto] R: Format







as posted some time ago from ken (?)

here:



add this function  to your page



function convert(a)

    convert = string(4 -len(a) , "0") + cstr(a)

end function





and then usage is



b = convert(4)

Response.Write b





Giovanni







-----Messaggio originale-----

Da: Andy@a... [mailto:Andy@a...]

Inviato: mercoledì 20 febbraio 2002 9.42

A: ASP Web HowTo

Oggetto: [asp_web_howto] Format





Hi



I have a number returned from a datsbase and I have to display it on a

page with leading zeros. IE if 4 is returned I have to display 0004.



I get type mismatch errors if I use format() and I can't get the leading

zeros with FormatNumber().



I need to do this with ASP because I have to send an email receipt of the

number in the correct format.



Any clues?



Andy Green




$subst('Email.Unsub').








$subst('Email.Unsub').










$subst('Email.Unsub').





Message #4 by pranot.mengle@b... on Thu, 21 Feb 2002 15:53:49 -0000
use Round() method in VBScript

eg. Round(411.25764646, 2) will return 411.26



> -----Original Message-----

> From:	Spam Free [SMTP:spam.free@n...]

> Sent:	Thursday, February 21, 2002 3:47 PM

> To:	ASP Web HowTo

> Subject:	[asp_web_howto] RE: R: Format

>

> Hi,

>

> I want to go the other way and round a number 2 decimal places

>

> e.g. make 411.25764646 display as 411.26 to places...

>

> ASP doesn't seem to like the format method I use in VB

> format (number, "0.00")

>

>

> Regards

> spam.free@n...

>

> ----- Original Message -----

> From: "Oleg Kapeljushnik" <c-oleg.kapeljushnik@w...>

> To: "ASP Web HowTo" <asp_web_howto@p...>

> Sent: Wednesday, February 20, 2002 2:32 PM

> Subject: [asp_web_howto] RE: R: Format

>

>

> Another way to do it is :

>

> Number =3D Right("0000" & Number)

>

> Oleg.

>

> -----Original Message-----

> From: Giovanni Salucci [mailto:g.salucci@n...]

> Sent: February 20, 2002 5:01 AM

> To: ASP Web HowTo

> Subject: [asp_web_howto] R: Format

>

>

>

> as posted some time ago from ken (?)

> here:

>

> add this function  to your page

>

> function convert(a)

>     convert =3D string(4 -len(a) , "0") + cstr(a)

> end function

>

>

> and then usage is

>

> b =3D convert(4)

> Response.Write b

>

>

> Giovanni

>

>

>

> -----Messaggio originale-----

> Da: Andy@a... [mailto:Andy@a...]

> Inviato: mercoled=EC 20 febbraio 2002 9.42

> A: ASP Web HowTo

> Oggetto: [asp_web_howto] Format

>

>

> Hi

>

> I have a number returned from a datsbase and I have to display it on 

a

> page with leading zeros. IE if 4 is returned I have to display 0004.

>

> I get type mismatch errors if I use format() and I can't get the 

leading

> zeros with FormatNumber().

>

> I need to do this with ASP because I have to send an email receipt of 

the

> number in the correct format.

>

> Any clues?

>

> Andy Green




> $subst('Email.Unsub').

>

>




> $subst('Email.Unsub').

>

>

>




> $subst('Email.Unsub').

>

>

>




> $subst('Email.Unsub').

Message #5 by "Craig Flannigan" <ckf@k...> on Thu, 21 Feb 2002 15:57:31 -0000

Use the Round command



--> Round(Number,Decimal Places)



E.g   <% =Round(411.25764,2)







-----Original Message-----

From: Spam Free [mailto:spam.free@n...]

Sent: 21 February 2002 15:47

To: ASP Web HowTo

Subject: [asp_web_howto] RE: R: Format





Hi,



I want to go the other way and round a number 2 decimal places



e.g. make 411.25764646 display as 411.26 to places...



ASP doesn't seem to like the format method I use in VB

format (number, "0.00")





Regards

spam.free@n...



----- Original Message -----

From: "Oleg Kapeljushnik" <c-oleg.kapeljushnik@w...>

To: "ASP Web HowTo" <asp_web_howto@p...>

Sent: Wednesday, February 20, 2002 2:32 PM

Subject: [asp_web_howto] RE: R: Format





Another way to do it is :



Number = Right("0000" & Number)



Oleg.



-----Original Message-----

From: Giovanni Salucci [mailto:g.salucci@n...]

Sent: February 20, 2002 5:01 AM

To: ASP Web HowTo

Subject: [asp_web_howto] R: Format







as posted some time ago from ken (?)

here:



add this function  to your page



function convert(a)

    convert = string(4 -len(a) , "0") + cstr(a)

end function





and then usage is



b = convert(4)

Response.Write b





Giovanni







-----Messaggio originale-----

Da: Andy@a... [mailto:Andy@a...]

Inviato: mercoledì 20 febbraio 2002 9.42

A: ASP Web HowTo

Oggetto: [asp_web_howto] Format





Hi



I have a number returned from a datsbase and I have to display it on a

page with leading zeros. IE if 4 is returned I have to display 0004.



I get type mismatch errors if I use format() and I can't get the leading

zeros with FormatNumber().



I need to do this with ASP because I have to send an email receipt of the

number in the correct format.



Any clues?



Andy Green




$subst('Email.Unsub').








$subst('Email.Unsub').










$subst('Email.Unsub').










$subst('Email.Unsub').



_____________________________________________________________________

This message has been checked for all known viruses by Star Internet

delivered through the MessageLabs Virus Scanning Service on behalf of

Kingfield Heath Ltd. For further information visit

http://www.star.net.uk/stats.asp





_____________________________________________________________________

This message has been checked for all known viruses by Star Internet

delivered through the MessageLabs Virus Scanning Service on behalf of Kingfield Heath Ltd. For further information visit
http://www.star.net.uk/stats.asp

Message #6 by "Spam Free" <spam.free@n...> on Thu, 21 Feb 2002 18:35:18 -0000
Cheers... knew there must be something simple.

Regards

spam.free@n...

----- Original Message -----

From: "Craig Flannigan" <ckf@k...>

To: "ASP Web HowTo" <asp_web_howto@p...>

Sent: Thursday, February 21, 2002 3:57 PM

Subject: [asp_web_howto] RE: R: Format





>

> Use the Round command

>

> --> Round(Number,Decimal Places)

>

> E.g   <% =Round(411.25764,2)

>

>

>

> -----Original Message-----

> From: Spam Free [mailto:spam.free@n...]

> Sent: 21 February 2002 15:47

> To: ASP Web HowTo

> Subject: [asp_web_howto] RE: R: Format

>

>

> Hi,

>

> I want to go the other way and round a number 2 decimal places

>

> e.g. make 411.25764646 display as 411.26 to places...

>

> ASP doesn't seem to like the format method I use in VB

> format (number, "0.00")

>

>

> Regards

> spam.free@n...

>

> ----- Original Message -----

> From: "Oleg Kapeljushnik" <c-oleg.kapeljushnik@w...>

> To: "ASP Web HowTo" <asp_web_howto@p...>

> Sent: Wednesday, February 20, 2002 2:32 PM

> Subject: [asp_web_howto] RE: R: Format

>

>

> Another way to do it is :

>

> Number = Right("0000" & Number)

>

> Oleg.

>

> -----Original Message-----

> From: Giovanni Salucci [mailto:g.salucci@n...]

> Sent: February 20, 2002 5:01 AM

> To: ASP Web HowTo

> Subject: [asp_web_howto] R: Format

>

>

>

> as posted some time ago from ken (?)

> here:

>

> add this function  to your page

>

> function convert(a)

>     convert = string(4 -len(a) , "0") + cstr(a)

> end function

>

>

> and then usage is

>

> b = convert(4)

> Response.Write b

>

>

> Giovanni

>

>

>

> -----Messaggio originale-----

> Da: Andy@a... [mailto:Andy@a...]

> Inviato: mercoledì 20 febbraio 2002 9.42

> A: ASP Web HowTo

> Oggetto: [asp_web_howto] Format

>

>

> Hi

>

> I have a number returned from a datsbase and I have to display it on a

> page with leading zeros. IE if 4 is returned I have to display 0004.

>

> I get type mismatch errors if I use format() and I can't get the leading

> zeros with FormatNumber().

>

> I need to do this with ASP because I have to send an email receipt of the

> number in the correct format.

>

> Any clues?

>

> Andy Green




> $subst('Email.Unsub').

>

>




> $subst('Email.Unsub').

>

>

>




> $subst('Email.Unsub').

>

>

>




> $subst('Email.Unsub').

>

> _____________________________________________________________________

> This message has been checked for all known viruses by Star Internet

> delivered through the MessageLabs Virus Scanning Service on behalf of

> Kingfield Heath Ltd. For further information visit

> http://www.star.net.uk/stats.asp

>

>

> _____________________________________________________________________

> This message has been checked for all known viruses by Star Internet

> delivered through the MessageLabs Virus Scanning Service on behalf of

Kingfield Heath Ltd. For further information visit

http://www.star.net.uk/stats.asp

>




$subst('Email.Unsub').



Message #7 by "Riia" <riia.mattila@m...> on Mon, 25 Feb 2002 14:28:03
...But be aware... Round-function might result some unexpected results 

(works like the CInt-function) if you want to round a number to an 

integer, for example:



Round(0.5,0) -> 0

Round(1.5,0) -> 2

Round(2.5,0) -> 2

Round(3.5,0) -> 4

Round(4.5,0) -> 4



This is not quite what my math teacher taught me about rounding numbers 

years back... ;o)



Riia





> Cheers... knew there must be something simple.

> Regards

> spam.free@n...

> ----- Original Message -----

> From: "Craig Flannigan" <ckf@k...>

> To: "ASP Web HowTo" <asp_web_howto@p...>

> Sent: Thursday, February 21, 2002 3:57 PM

> Subject: [asp_web_howto] RE: R: Format

> 

> 

> >

> > Use the Round command

> >

> > --> Round(Number,Decimal Places)

> >

> > E.g   <% =Round(411.25764,2)


  Return to Index