Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2005
    Posts
    313

    How to convert String to Currency in VB Code

    Hi
    In VB Code,

    how to convert String to Currency, and also, Currency is Standard form (eg 2334.00, NO dollar sign$)

    Please let me know, thanks.

  2. #2
    Join Date
    Dec 2003
    Posts
    268

    Conversion

    To convert a string to currency

    ccurr(yourstring)

    this will only work if the string is stored as a translateable string. You can't convert "Hello" to currency. Just keep that in mind.

    Second question, No, the '$' is not stored as part of currency.
    Currency is a variable type, and determines how the decimal is handled and rounding etc. How the data are presented is not determined by the variable type.

  3. #3
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,275
    accessman2:
    Would like to see this master piece you are building

    some VB CODE 101

    val([string]) will change the string to number
    str([number]) will chnage the number to string

    if you are in MSaccess in you querys in the feild line

    you can NewFeildName:Val([filename])

    or

    NewFeildName:Format([filename],"###.00")
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE

  4. #4
    Join Date
    Sep 2005
    Location
    Schaumburg, IL
    Posts
    28
    Quote Originally Posted by accessman2
    Hi
    In VB Code,

    how to convert String to Currency, and also, Currency is Standard form (eg 2334.00, NO dollar sign$)

    Please let me know, thanks.
    Hi. I dont know exactly what you wish to do hoping this will help...
    Lets say your in the queries view and theres a column you want to convert into numeric but there might be some ALPHABET value which you cannot convert it....

    Assuming table name is TEST and Field Name is FIELD1

    SELECT IIF(IsNumeric(FIELD1),VAL(FIELD1),0) AS Output FROM TEST


    You can use the combination of IIF function and IsNumeric

  5. #5
    Join Date
    Sep 2005
    Location
    Schaumburg, IL
    Posts
    28
    I forgot the dollar sign, you can take it off in the Design Mode of your table...
    Try to select the Currency Field and change the Format, instead of Currency, try changing it into General Number. It will take off your $ sign.

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    12,426
    The currency symbol is specified by your systems internationalisation configuration, so if your computer 'thinks' it is in a dollar country (or hasn't been set up_ it will show a $ symbol. If its incorrect set the symbol via start | control panel | internationalisation

    alternatively
    if you don't want a currency symbol: as myle suggests use a general number format. Althgough I'd suggest
    NewFieldName:Format([filename],"#,##0.00") will give a currency style formatting.
    eg 0.99
    9,001.25

    bear in mind though that if you are displaying currency information that some beancounters get very upset if the totals & subtotals don't tally exactly. so you may need to use something like fix(myvar,nodecimals) to ensure that the sum of the rows equals the total
    HTH

Posting Permissions

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