Results 1 to 4 of 4

Thread: If the search was working I probably wouldn't have to ask this, but:

  1. #1

    Thread Starter
    Hyperactive Member Al Smith's Avatar
    Join Date
    May 1999
    Location
    Marcellus, MI. USA
    Posts
    330

    If the search was working I probably wouldn't have to ask this, but:

    Hi,
    Can a number be formatted in ASP?
    I'm retreiving data from a data base and writing it to an HTML table. Some of the data is price information. I'm trying to get it to show up in the table as a price.
    I've tried using the Format function in ASP but it's giving me an error. e.g.,
    Code:
    <%ItemPryc = Format(Cdbl(rs.fields(4).value),"$##0.00")%>
    Thanks,
    Al.
    A computer is a tool, not a toy.

  2. #2
    rsitogp
    Guest
    First try, then ask.

  3. #3
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    Well.. that was helpful..

    The Format function is not available in VBScript. You must use the FormatCurrency, FormatDateTime, FormatNumber, FormatPercent functions.

    I can't for the life of me figure out why MS left out this useful function, (Maybe because it is so slow) but they did.
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  4. #4

    Thread Starter
    Hyperactive Member Al Smith's Avatar
    Join Date
    May 1999
    Location
    Marcellus, MI. USA
    Posts
    330

    Thank you Monte96

    Thanks. That's alot easier and sanitary then my work-around below.

    Code:
    <%
    If Cint(ItemPryc)-Cdbl(ItemPryc)=0 then
    	ItemPryc=ItemPryc & ".00"
    End If
    If Len(ItemPryc)-Instr(ItemPryc,".")=1 then
    	ItemPryc=ItemPryc & "0"
    End If
    %>
    Al.
    A computer is a tool, not a toy.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width