[wellylug] Microsoft Question Time - Formatting Text Fields in Visual Basic
Nick Jensen
spoonfella at hotmail.com
Thu Jul 15 09:28:23 NZST 2004
>I know that this is not a linux question but I am totally stuck. I have the
>MSDN Libray for Visual Studio 6.0 installed and it has some code sample and
>ideas, but I can't get them to work for me.
>
>I'm writing a visual basic front end to an Access database for a client. I
>have got it reading / writing to the database using Microsoft Jet drivers.
>
>I have text box that displays a currency amount except at the moment is
>just
>looks like plain numbers. The database itself is set to currency for this
>field. How do I get the field to display in currency mode (ie: $55.66)
>without this formatting going into the database.
More info needed.
Are you filling a recordset and using the data in the recordset to fill the
textbox? In that case you can use:
text1.Text = Format(rs!CurrencyValue, "$#,###,##0.00")
and save it back to the recordset using:
rs!CurrencyValue = CDbl(text1.Text)
If you are using a 'data' control on the form, and are filling the textbox
using it's 'DataSource' property, this is a bit trickier. You could try to
use the OnChange event:
Private Sub text1_OnChange()
text1.Text = Format(text1.Text, "$#,###,##0.00")
End Sub
Saving back to the db won't be a problem because the formatting will be
ignored.
If neither of these answers your question, you'll need to explain how you
are filling your textbox's more clearly.
Nick
_________________________________________________________________
Theres never been a better time to get Xtra JetStream @
http://xtra.co.nz/jetstream
More information about the wellylug
mailing list