Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 395
  • Last Modified:

How to Set up currency and percent into a VB text box output ?

Hey whats up experts.

I have something very simple and I'm sure many people have asked before, but I was wondering how do I set up an output in a text box
to display a Double value to been seen as Currency $ and as well as Percent %.

here I have a sample code and I just want to know how to format them.

///////

Dim CarTotal As Double = txtTotalAMT.Text
            Dim DownPayment As Double = txtDownPayment.Text

            Dim TotalCarAMOUNT As Double

            TotalCarAMOUNT = CarTotal - DownPayment

            txtAmountFinance.Text = TotalCarAMOUNT

////////

I know very simplistic coding lol

Thankyou in advance guys

0
masterat03
Asked:
masterat03
  • 3
  • 2
  • 2
  • +1
1 Solution
 
masterat03Author Commented:
So um...any out there that could help with this ?
0
 
snow_moonCommented:
Try FormatCurrency( ) and FormatPercent( ) functions.
0
 
ZeonFlashCommented:
--For 2 decimal places in currency, ie $1,000.00
txtAmountFinance.Text = FormatCurrency(TotalCarAMOUNT, 2)

-For 2 decimal places in percentage, ie 0.25%
TextBox1.Text = FormatPercent(ThePercent, 2, TriState.True)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
wtconwayCommented:
No no no no.

Dim DownPayment as Double = txtDownPayment.Text
Dim TotalCarAMOUNT as Double = CarTotal - DownPayment
txtAmountFinance.Text = TotalCarAMOUNT.ToString("c") 'will output formatted as currency
the percentage values for whatever your calculating is .ToString("p") for percent
0
 
ZeonFlashCommented:
The .ToString method works well too, but it depends on how much customization of the strings you need.
0
 
masterat03Author Commented:
Sorry Guys I was away for a bit. Anyhow I like both methods (ZeonFlash) and (wtconway) , but for now what I really need is something quick and swift like Zeonflash has it. Although I do agree if I need to do more customization I would go with your method wtconway.

0
 
wtconwayCommented:
Well actually, I believe ZeonFlash's method would allow for more customization. The method I suggested is the quickest and dirtiest way to do it.
0
 
wtconwayCommented:
The reason my code looks bloated is because I added your variables and calculations from your original question to show you how it would work in your scenario. It really is a simple way to display currency or percentage values on a Double datatype:

TotalCarAMOUNT.ToString("c") would display something like "$25,000.00"
SomePercentage.ToString("p") would display something like "33%"

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now