本文介绍了输入字符串格式不正确时发生错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的编码
< pre lang =vb> For each Me.dgMaterial in dtgreorderlevelsummary.Rows 如果Convert.ToDouble(CType(dgMaterial.FindControl(quantity),TextBox).Text)+ Convert.ToDouble(CType(dgMaterial.FindControl(count),Label).Text)> 0然后j = j + 1 结束如果 next解决方案
并非一切都可以转换加倍!例如 lekha g nair 不能...... 检查texbox中的值 - 使用调试器 - 看看你尝试转换的值是多少... 您还可以查看 Double .TryParse [ ^ ]方法......
使用 Val (CType(dgMaterial.FindControl(quantity) ),TextBox).Text) 在转换宫殿中的 您的问题得到解决。
This is my coding
<pre lang="vb">For Each Me.dgMaterial In dtgreorderlevelsummary.Rows If Convert.ToDouble(CType(dgMaterial.FindControl("quantity"), TextBox).Text) + Convert.ToDouble(CType(dgMaterial.FindControl("count"), Label).Text) > 0 Then j = j + 1 End If next 解决方案 Not everything can be converted to double! For instance lekha g nair can not... Check the values in the texbox - use debugger - to see what value do you try to convert... You may also check Double.TryParse[^] method...Use Val(CType(dgMaterial.FindControl("quantity"), TextBox).Text) in palace of Convert.toDouble Your problem get resolved.更多推荐
输入字符串格式不正确时发生错误
发布评论