試圖將其轉換爲十進制給出錯誤 是gridview的從字符串「」轉換爲輸入「小數」無效。 - VB
e.Row.Cells(i).Text = If(CType(e.Row.Cells(total).Text, Decimal) = 0, "-", (CType(e.Row.Cells(total).Text, Decimal) * 100/CType(e.Row.Cells(total).Text, Decimal)).ToString("0.00") + "%")
試圖將其轉換爲十進制給出錯誤 是gridview的從字符串「」轉換爲輸入「小數」無效。 - VB
e.Row.Cells(i).Text = If(CType(e.Row.Cells(total).Text, Decimal) = 0, "-", (CType(e.Row.Cells(total).Text, Decimal) * 100/CType(e.Row.Cells(total).Text, Decimal)).ToString("0.00") + "%")
Dim temp As Decimal
temp=0
IF Decimal.TryParse(e.Row.Cells(total).Text, temp) THEN
e.Row.Cells(i).Text = If(temp = 0, "-", (temp * 100/temp).ToString("0.00") + "%")
ELSE e.Row.Cells(i).Text = "-"
的行單元格請幫助! TXXX –
嘗試使用TryCast代替CType – N1gthm4r3
它給出--Error 'TryCast'操作數必須是引用類型,但'Decimal'是值類型。 –