Wrox Programmer Forums
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old October 26th, 2006, 06:29 AM
Registered User
Join Date: May 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default ADO2.6 currency formatting


I have a fabricated recordset and I'm having problem formatting the correct figures. I have defined my fields like

.Append "Debit Credit", adChar, 6
.Append "Currency", adChar, 3
.Append "Amount", adCurrency
rsAgentPostings("Debit Credit") = "Credit"           
rsAgentPostings("Currency") = "GBP"           
rsAgentPostings("Amount") = Format("1507.5000000", "###,###,##0.00")
Even though I have specified the formatting when I check the value in rsAgentPostings("Amount") its 1507.5 instead of 1,507.50.

I changed the datatype to adChar and the length to 50 and it formats correctly, but in the grid we use (UltraGrid) its left justified when i force it to right justify the value disapears - bah. So I have changed the datatype back too adCurrency.

So my question is why isnt the field formating correctly? ie 1507.5 instead of 1,507.50

Thanks in advance

Old October 31st, 2006, 07:09 PM
Friend of Wrox
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts

The machinery that stores and retrieves the values—the database engine—stores the real value. Just as there are no zeros to the left of 1507.5 (eg, 0001507.5), there are none to the right. Just as 1×10^1 + 0×10^1 + 5×10^2 + 1×10^3 is the same as 1×10^1 + 0×10^1 + 5×10^2 + 1×10^3 + 0×10^4, 5×10^-1 + 0×10^-2 = 5×10^-1. There is no meaning to storing the zeros.

The rest is just display instructions. (Not much help, I know, but that's the reason.)
Old October 31st, 2006, 07:20 PM
Friend of Wrox
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts

If you want to store a formatted amount, you will need to have a datatype that stores a string. As Brian is implying, a column with a data type of adCurrency is storing the amount only, not the formatting.

Woody Z http://www.learntoprogramnow.com

Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting currency drmacy BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 2 September 20th, 2007 04:59 PM
Currency mjbkelly Beginning VB 6 1 March 22nd, 2007 07:14 AM
XSQL date and currency formatting c3008212 XSLT 0 March 18th, 2006 08:52 AM
Formatting currency chelechele JSP Basics 0 April 5th, 2005 06:00 PM
Currency value in textboxes mahulda ASP.NET 1.0 and 1.1 Basics 1 April 6th, 2004 02:10 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.