Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Currency format in code Not recognised 2

Status
Not open for further replies.

SpankYou

Programmer
Feb 24, 2003
211
GB
Hey,

This problem has me baffled. In a textbox, which is bound I display a price per share. I have set the format to currency, and everything displays fine. But in code I am trying to copy the value exactly as it is displayed in the textbox. Now I have tried the following methods.

The value displayed in the textbox (for example)is £0.40, but all the code tests I have done, read the value from the text box as "0.4" without the leading pound sign and last 0. "I need this displayed as is , because I am using it in in a word document"

What Ive tried...

Test 1

Dim CurPricePerShare as Currency
CurPricePerShare = Me.TxtPricePerShare

Test 2
Dim CurPricePerShare as Currency
CurPricePerShare = Format$(Me.PricePerShare, "£###.##")

Test 3
Dim CurPricePerShare as Currency
CurPricePerShare = CCur(CurPricePerShare)

Test 4
Dim StrCurPricePerShare as String
StrCurPricePerShare = Me.TxtPricePerShare

Test 5
Dim CurPricePerShare as Currency
CurPricePerShare = Me.TxtPricePerShare.Value

I've tried all of these and more, If any one has any ideas please let me know, I'm going crazzy! I'm losing my mind!

Cheers


Sam

"You couldn't fool your mother on the foolingest day of your life if you had an electrified fooling machine." - Homer
 
Have you tried this ?
Dim strPricePerShare As String
strPricePerShare = Format$(Me.PricePerShare, "£###.##")

Hope This Help
PH.
 
In your format string you may want to try "0.00" to get the leading and trailing zeros.
 
Hey,

Thanks for the idea PHV, i've just tried it but the result I get is "£.4". But Cor Blimey Guvnor jges example, gives me the format apart from the "£", so I've mixed them together and it works...

strPricePerShare = Format$(Me.PricePerShare.Value, "£0.00")

Thanks to you both for the help.

Cheers


Sam

"You couldn't fool your mother on the foolingest day of your life if you had an electrified fooling machine." - Homer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top