troubleshooting Question

VB.NET Text Box Formatting

Avatar of fizzlefry
fizzlefry asked on
Microsoft AccessProgrammingVisual Basic.NET
4 Comments1 Solution806 ViewsLast Modified:
I have several text boxes on a VB form that feed into a database.  There is no binding.  I do everything in code using SQL / vb code.  I can't seem to find a good solution to the following:

in any of my text boxes (which I understand I may have to specify separately), I need to format the number entered by the user to display as currency.  Meaning, if user enters "5", on the OnLeave function of the box, I'd like to format this as "5.00" (no dollar sign needed).  BUT if the user enters ".10", it needs to translate to "0.10".  I have been unable to find a solution that accomplishes both.  This works, but ONLY for whole numbers:

Dim amount As Decimal = CType(txtFinalDrop.Text, Decimal)
Me.txtFinalDrop.Text = String.Format("{0:n2}", amount)

I've tried masked text boxes, but I find myself in the same situation.  I've searched Google to no avail.  There has to be a clean way to do this.  Any help would be more than appreciated.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros