输入字符串格式不正确时发生错误

编程入门 行业动态 更新时间:2024-10-24 01:58:02
本文介绍了输入字符串格式不正确时发生错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是我的编码

< 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.

更多推荐

输入字符串格式不正确时发生错误

本文发布于:2023-10-18 11:16:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1504081.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   不正确   发生错误   格式

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!