If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > How to convert String to Currency in VB Code

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
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.
Reply With Quote
  #2 (permalink)  
Old
Registered User
 
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.
Reply With Quote
  #3 (permalink)  
Old
(Making Your Life Easy)
 
Join Date: Feb 2004
Location: New Zealand
Posts: 1,273
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
Reply With Quote
  #4 (permalink)  
Old
Registered User
 
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
Reply With Quote
  #5 (permalink)  
Old
Registered User
 
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.
Reply With Quote
  #6 (permalink)  
Old
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 12,063
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On