2017-08-31 18 views
0

進数に変換しようとすることは、GridViewの文字列 ""から "10進数"への変換は無効です。 - 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") + "%") 
+0

の行のセルでエラー を与える助けてください! TXXX –

+0

CType – N1gthm4r3

+0

の代わりにTryCastを試してください - エラー 'TryCast'オペランドは参照型でなければなりませんが、 'Decimal'は値型です。 –

答えて

1
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 = "-" 
+0

"out"が動作しない –

+0

@StavanShahの代わりに 'Decimal out 'の代わりに' temp'に切り替えるとちょっと混乱していると思います:) – Jaxi

+0

このコードには 'End If'がありません。 –

関連する問題