Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27356

Format Textbox as negative Currency only

$
0
0
I have 2 textboxes that are formated as currency but one is only going to be for negative currency like a coupon... say $.50 off.

So my current code is
Code:

txtCoupon_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtCoupon.Validating

        'if theres nothing entered default it to 0.00
        If txtCoupon.Text.Length = 0 Then txtCoupon.Text = "$0.00"
        'convert the text to a value
        Dim dblAmt As Double = Decimal.Parse(txtCoupon.Text, Globalization.NumberStyles.Currency)
        'convert it for display
        txtCoupon.Text = dblAmt.ToString("c")

This so if i enter .50 then it comes out $.50. What i am looking for is if i enter .50 it comes out as ($.50) meaning $.50 off the price. This is so the user does not have to manually enter -.50 just .50

Viewing all articles
Browse latest Browse all 27356

Trending Articles