我正嘗試解析字符串轉換成十進制,但我不斷收到一個出現FormatExceptionVB.Net轉換ToDecimal不需額外工作,逗號
Dim row as GridViewRow
for each row in grdActieRittenActiefAlt.rows
Dim rbl as RadioButtonList = row.FindControl("tblAddAct")
'toevoegen = true
if rbl.SelectedItem.Value = true then
Dim opgaveIdent as Integer = Convert.ToInt32(grdActieRittenActiefAlt.DataKeys(row.RowIndex).Value.ToString())
Dim curOldTarief as Decimal = Convert.ToDecimal(lblCuratiefTarief.Text)
Dim curOldKorting as Decimal = Convert.ToDecimal(lblCuratiefKorting.Text)
Dim curTariefString as String = row.Cells(4).Text
Dim curKortingString as String = row.Cells(6).Text
Dim curTarief as Decimal = Convert.ToDecimal(curTariefString)
Dim curKorting as Decimal = Convert.ToDecimal(curKortingString)
lblCuratiefTarief.Text = (curOldTarief + curTarief).ToString()
lblCuratiefKorting.Text = (curOldKorting + curKorting).ToString()
end if
next row
輸入是431,25。
到目前爲止,我已經試過如下:
有沒有人有任何建議?
程序運行的文化是什麼?你試過'Decimal.Parse'嗎? – Oded
我無法通過替換 - 'Convert.ToDecimal(「431,25」.Replace(',','。'))''在'431.25'中產生結果。使用具有「fr-FR」文化的'Decimal.Parse'也能像預期的那樣工作。 – Oded
Decimal.Pase給出了相同的結果。該文化是NL-NL。 – Sand0rf