Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Putting a decimal in results - ASP?

  • 21-04-2008 9:36am
    #1
    Registered Users, Registered Users 2 Posts: 1,477 ✭✭✭


    Does anyone know how to take a returned value from a MYSQL DB, in ASP and always place a decimal point two digits to the left?

    I have a very simple ASP page that connects to a MYSQL DB and returns a value, below is the code:

    userid = Request.Form("USERNAME")
    objConn.Open(sConnection)
    Set objRS = objConn.Execute("SELECT * FROM tbluseracct where actUserID = '" & USERID &"'")

    The value come back fine but its held in interger format, i.e 1435 would mean €14.35. Does anyone know a simple way to take this value and format it correctly in the output? I can add the € sign fine but I am not sure about adding the decimal in 2 place every time?

    Newbie BTW, in case I insult anyone!


Comments

  • Registered Users, Registered Users 2 Posts: 706 ✭✭✭DJB


    you can do something like this within your loop:

    sValue = rs("Value") 'this gets the value of 1435 into a variable. amend to suit your naming conventions
    sValueNew = "&euro" & Left(sValue,len(sValue)-2) & "." & Right(sValue,2)

    sValueNew now has the formatted value in it.

    HTH

    Dave


  • Registered Users, Registered Users 2 Posts: 1,477 ✭✭✭azzeretti


    DJB wrote: »
    you can do something like this within your loop:

    sValue = rs("Value") 'this gets the value of 1435 into a variable. amend to suit your naming conventions
    sValueNew = "&euro" & Left(sValue,len(sValue)-2) & "." & Right(sValue,2)

    sValueNew now has the formatted value in it.

    HTH

    Dave

    Thanks for this, but one question....will this work for a result like 10000 that should be 100 euro? Thanks


  • Registered Users, Registered Users 2 Posts: 6,465 ✭✭✭MOH


    Just divide it by 100?


  • Registered Users, Registered Users 2 Posts: 2,931 ✭✭✭Ginger


    Why not try the uber sekrit FormatCurrency function...

    http://www.w3schools.com/vbscript/func_formatcurrency.asp

    First divide by 100 and then apply the format


Advertisement