Click to See Complete Forum and Search --> : formatting data in MSHFlexGrid


chaseltine
December 21st, 1999, 05:33 PM
Does anyone know how you would go about formatting a column of data in a bound MSHflexGrid to display a $000.00 format?

I have a bound MSHFlexGrid to an ado object, with an Access 97 database on the back end. I am displaying one column in the FlexGrid which contains a "monetary" value. I've tried using a text datatype for this field in Access, and defining an input mask property to store the values for this field in a $000.00 format. I've also tried changing the data type in Access to Currency, although I would prefer to store the value as text only. Neither of these approaches work, the column of data is displayed in the MSHFlexGrid as just a line of numbers (23455) with no decimal point and no preceeding $.

Any advice or ideas would be greatly appreciated!!!!

chaseltine

Chris Eastwood
December 22nd, 1999, 05:40 AM
You could try something like :


Dim sValue as string
Dim lYourColumnNumber as Long

lYourColumnNumber = 1

With MSHFlexGrid1
.Redraw = false ' makes it about 10x faster !
for lCount = .FixedRows to .Rows - 1
sValue = MSHFlexGrid1.TextMatrix(lCount, lYourColumnNumber)
sValue = Format$(sValue, "$###,###,###.##")
MSHFlexGrid1.TextMatrix(lCount, lYourColumnNumber) = sValue
next
.ColAlignment(lYourColumnNumber) = flexAlignRightCenter
.Redraw = true ' dont forget to do this !
End With





Chris Eastwood

CodeGuru - the website for developers
http://codeguru.developer.com/vb

chaseltine
December 22nd, 1999, 09:57 AM
Chris,

Thank you!!! Now that I see the code, I'm embarrassed to admit that I wasn't able to figure out how to do it myself. But I guess this close to the holidays, with one last bug fix to make before I can take vacation, I'm too burned out to even think straight.

Have a Merry Christmas, and a Safe and Happy New Year.


chaseltine