Vb.net 十进制错误中的字符串

Vb.net 十进制错误中的字符串,vb.net,visual-studio-2010,sql-server-2008,vb.net-2010,Vb.net,Visual Studio 2010,Sql Server 2008,Vb.net 2010,我有一个文本框,其值为0.00,然后我得到一个错误转换。。。但我 已经用0.00制作了一个示例,但它不是从文本框中创建的,并且正在运行。。如何解决此问题 Dim _Total, _Deduct, _Charges As String Dim _sss, _tax, _pf, _ph, _loan, _others, _hdmf, _cola, _allowance As Decimal 如果文本框和注释中有此行,则此行有效。。但是我用这个不起作用 _sss = txtS

我有一个文本框,其值为0.00,然后我得到一个错误转换。。。但我 已经用0.00制作了一个示例,但它不是从文本框中创建的,并且正在运行。。如何解决此问题

    Dim _Total, _Deduct, _Charges As String
    Dim _sss, _tax, _pf, _ph, _loan, _others, _hdmf, _cola, _allowance As Decimal
如果文本框和注释中有此行,则此行有效。。但是我用这个不起作用

    _sss = txtSSS.Text : _ph = txtPH.Text : _tax = txtInTax.Text : _pf = txtPF.Text
    _loan = txtLoan.Text : _hdmf = txtHDMF.Text : _others = txtOther.Text
    _cola = txtCola.ToString : _allowance = txtAllowance.ToString
这一行是我给出的示例值。。。相同的值,但文本框不起作用。。这是有效的

    'This code when I uncomment.. this work..
    '_sss = "0.00": _ph = "0.00" : _tax = "0.00" : _pf = "0.00"
    '_loan = "0.00" : _hdmf = "50.00" : _others = "0.00"
    '_cola = "0.00" : _allowance = "0.00"

    _Charges = CDec(_cola) + CDec(_allowance)
    _Deduct = CDec(_sss) + CDec(_tax) + CDec(_pf) + CDec(_ph) + CDec(_loan) + CDec(_hdmf) + CDec(_others)

    _Total = CDec(_Charges) - CDec(_Deduct)

    lblDeduct.Text = Format((_Deduct), "currency")
    lblTotal.Text = FormatCurrency((_Total), 2, TriState.True, TriState.False, TriState.True)
使用:


隐马尔可夫模型。。先生如果textbox的值是动态的,并且可以通过textchange进行更改,该怎么办。。我真的不知道该怎么做。。答案是…@deorwinbensur把它放在文本框的TextChanged event中仍然不知道解决这个问题的好方法,先生。。我实际使用的是货币价值的计算。。但仍然没有解决。。
<!-- language : lang-vb -->
If Not Decimal.TryParse(txtSSS.Text, _sss) Then
    ' do something if the value doesn't convert
End If
Private Sub CalculateCurrency()
    If Not Decimal.TryParse(txtSSS.Text, _sss) Then _sss = 0D
    If Not Decimal.TryParse(txtPH.Text, _ph) Then _ph = 0D
    If Not Decimal.TryParse(txtInTax.Text, _tax) Then _tax = 0D
    If Not Decimal.TryParse(txtPF.Text, _pf) Then _pf = 0D
    If Not Decimal.TryParse(txtLoan.Text, _loan) Then _loan = 0D
    If Not Decimal.TryParse(txtHDMF.Text, _hdmf) Then _hdmf = 0D
    If Not Decimal.TryParse(txtOther.Text, _others) Then _others = 0D
    If Not Decimal.TryParse(txtCola.Text, _cola) Then _cola = 0D
    If Not Decimal.TryParse(txtAllowance.Text, _allowance) Then _allowance = 0D

    _Charges = CStr(_cola + _allowance)

    _Deduct = CStr(_sss + _tax + _pf + _ph + _loan + _hdmf + _others)

    _Total = CStr(CDec(_Charges) - CDec(_Deduct))

    lblDeduct.Text = Format((_Deduct), "currency")
    lblTotal.Text = FormatCurrency((_Total), 2, TriState.True, TriState.False, TriState.True)
End Sub