从字符串转换“ "键入'Decimal'无效。 - VB [英] Conversion from string " " to type 'Decimal' is not valid. - VB

查看:122
本文介绍了从字符串转换“ "键入'Decimal'无效。 - VB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图将其转换为十进制给出错误
它是gridview的行单元

trying to convert it to decimal gives error it is row cell of gridview

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 = "-"

这篇关于从字符串转换“ "键入'Decimal'无效。 - VB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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