格式百分比问题 [英] Format percent problem

查看:128
本文介绍了格式百分比问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在表单上有一个带遮罩的文本框,其格式设置为"0.00"
我试图将其更改为"00.00",以便使12.50%起作用.这样就可以了.如果它是7%的税,即使我输入07.00,我最终也会得到70.00 ...这给了我错误的金额.如何正确格式化?
在数据库中,它是百分比数据类型.即数据类型是数字,百分比格式和设置为自动(访问数据库)的十进制空格
我已注释掉无效的内容.
-------------------------------------------------- --------------

I have a masked textbox on the form and it''s formatted "0.00"
I tried to change it to "00.00" so that 12.50 percent works. So thats fine..however; if it''s 7% tax I end up with 70.00 even when I input 07.00... which gives me the wrong amounts. How do I format it correctly?
In the database it is percent data type. Ie data type is number, percent as format and decimal spaces set to auto (access database)
I have commented out what does not work.
----------------------------------------------------------------

Public Sub BindControls()
1:      txtSalesTaxName1.DataBindings.Add("Text", SalesTaxIDTable, "SalesTaxName1")
2:      txtName2.DataBindings.Add("Text", SalesTaxIDTable, "SalesTaxName2")
3:      txtName3.DataBindings.Add("Text", SalesTaxIDTable, "SalesTaxName3")
        ''////////////////////////////////
        ''Dim d As Decimal = CDec(Me.txtAmt1.Text)
        ''Me.txtAmt1.Text = Decimal.ToDouble("f2")
        ''txtAmt1.DataBindings.Add("Text", SalesTaxIDTable, "SalesTaxAmt1", True, DataSourceUpdateMode.OnPropertyChanged, 0, "P") ''("{0:P}", 
        ''txtAmt1.DataBindings(0).FormatString = "P"
        txtAmt1.Mask = "00.00"
        '' txtAmt1.DataBindings.Add("Text", SalesTaxIDTable, "SalesTaxAmt1", True, DataSourceUpdateMode.OnPropertyChanged, 0, "P")
        txtAmt2.Mask = "0.00"
        '' txtAmt2.DataBindings.Add("Text", SalesTaxIDTable, "SalesTaxAmt2", True, DataSourceUpdateMode.OnPropertyChanged, 0, "P")
        txtAmt3.Mask = "0.00"
        ''txtAmt3.DataBindings.Add("Text", SalesTaxIDTable, "SalesTaxAmt3", True, DataSourceUpdateMode.OnPropertyChanged, 0, "P")
4:      txtAmt1.DataBindings.Add("Text", SalesTaxIDTable, "SalesTaxAmt1")
5:      txtAmt2.DataBindings.Add("Text", SalesTaxIDTable, "SalesTaxAmt2")
6:      txtAmt3.DataBindings.Add("Text", SalesTaxIDTable, "SalesTaxAmt3")
        If Int32.TryParse(Me.txtAmt1.Text, New Integer) AndAlso Me.txtAmt1.Text =0 AndAlso Me.txtAmt1.Text=100 Then
            Me.txtAmt1.Text = FormatPercent(Me.txtAmt1.Text / 100, 2)
        Else
            '' Me.txtAmt1.Text = String.Empty
        End If
        ''[/////////////////////////////////////////
        If Int32.TryParse(Me.txtAmt2.Text, New Integer) AndAlso Me.txtAmt2.Text = 0 AndAlso Me.txtAmt2.Text = 100 Then
            Me.txtAmt2.Text = FormatPercent(Me.txtAmt2.Text / 100, 2)
        Else
            ''Me.txtAmt2.Text = String.Empty
        End If
        ''///////////////////////////////////////////////////////////////////////////////////////
        If Int32.TryParse(Me.txtAmt3.Text, New Integer) AndAlso Me.txtAmt3.Text = 0 AndAlso Me.txtAmt3.Text = 100 Then
            Me.txtAmt3.Text = FormatPercent(Me.txtAmt3.Text / 100, 2)
        Else
            '' Me.txtAmt3.Text = String.Empty
        End If
        ''////////////////////////////////////////////////////////////////
7:      TxtTaxID.DataBindings.Add("Text", SalesTaxIDTable, "SalesTaxID")
    End Sub

推荐答案

应该以我认为的另一种方式定义掩码.

尝试:"9#.##"

有关掩码值的更多信息:
http://msdn.microsoft.com/en-us/library/e4cw90af%28v = VS.71%29.aspx [ ^ ]

祝你好运!
The mask should be defined in another way I think.

Try: "9#.##"

More info on the mask value:
http://msdn.microsoft.com/en-us/library/e4cw90af%28v=VS.71%29.aspx[^]

Good luck!


这篇关于格式百分比问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆