输入字符串格式不正确时发生错误 [英] Error occured as input string was not in correct format

查看:85
本文介绍了输入字符串格式不正确时发生错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的编码



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


这篇关于输入字符串格式不正确时发生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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