How to Make a Text Box Display As Currency in Visual Basic 2005

How to Make a Text Box Display As Currency in Visual Basic 2005 thumbnail
The MaskedTextBox control is used to display currency values.

When you create user forms in Visual Basic 2005, you may need to display currency. Currency displays show the user a number with two decimal points and the dollar symbol. Visual Basic has a "MaskedTextBox" control that you can use to create a currency text box. The control looks like a typical text box to the user, but it has a "Mask" property for the programmer to display currency. This control is used to display dates, numbers, dates and phone numbers.

Instructions

    • 1

      Open your Web or desktop project in Visual Studio. Double-click the form in the Solution Explorer. This opens your form in design view.

    • 2

      Drag and drop the "MaskedTextbox" control from your toolbox to the form. This creates the control for you on the form. Click the control and enter "myCurrencybox" into the "Name" property field located on the right of your work console.

    • 3

      Enter "$#,###.00" into the property labeled "Mask." This places a comma at the thousandth place and always formats the number for two decimal places. Additionally, the dollar sign is prefixed to the number.

    • 4

      Save the form and press the F5 key. This runs the project in debug mode. View the new code in the debugger to verify it compiles and runs properly.

Related Searches:

References

  • Photo Credit dollar sign image by Alexander Zhiltsov from Fotolia.com

Comments

You May Also Like

Related Ads

Featured