Currency Format In Textbox

J

Joe

Hi,

I am storing a field in SQL Server with a datatype of money.
When I pull that field back into my VB.NET client program, I put it
into a typed dataset with a field type of System.Decimal.

When it displays in the textbox that I have tied to the
dataset, it appears as 4000.0000 but I want it to appear as $4,000.00

How can I achieve this format in my textbox? Remember that
the underlying field is a Money datatype and not a string datatype.


J
 
H

Harry

Joe said:
Hi,

I am storing a field in SQL Server with a datatype of money.
When I pull that field back into my VB.NET client program, I put it
into a typed dataset with a field type of System.Decimal.

When it displays in the textbox that I have tied to the
dataset, it appears as 4000.0000 but I want it to appear as $4,000.00

How can I achieve this format in my textbox? Remember that
the underlying field is a Money datatype and not a string datatype.


J

Couple of options I can think of:
1. Use data binding. This allows for optional formatting of the text box
2. Use the CONVERT function in Sql eg SELECT CONVERT(MyMoney, varchar) AS
MyMoney

If you use the second option, you will have to lookup the CONVERT function
in Sql. The above example returns two decimal places by default. There is a
third parameter for the CONVERT function that alters output.
 
T

Tony K

Me.UnitPriceMaskedTextBox.Text = Format(Val(Me.UnitPriceMaskedTextBox.Text),
"c2")

Tony K
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top