错误:从字符串“"的转换输入“整数"无效 [英] Error: Conversion from string "" to type 'Integer' is not valid

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

问题描述

Select Case dlg
        Case Windows.Forms.DialogResult.Yes
            If TextBox12.Text = "" Then
                Dim a, b, c As Integer
                a = TextBox7.Text
                b = TextBox8.Text //my problem
                c = TextBox11.Text
                TextBox12.Text = a + b - c
            End If
            If TextBox6.Text = "" Then
                TextBox6.Text = "-"
            End If

我不知道如何解决这个错误:

I don't know how to fix this error:

从字符串 "" 到类型 'Integer' 的转换无效

Conversion from string "" to type 'Integer' is not valid

推荐答案

尝试使用 Integer.Parse:

Try using Integer.Parse:

Select Case dlg
        Case Windows.Forms.DialogResult.Yes
            If TextBox12.Text = "" Then
                Dim a, b, c As Integer
                a = Integer.Parse(TextBox7.Text)
                b = Integer.Parse(TextBox8.Text) //my problem
                c = Integer.Parse(TextBox11.Text)
                TextBox12.Text = a + b - c
            End If
            If TextBox6.Text = "" Then
                TextBox6.Text = "-"
            End If

这篇关于错误:从字符串“"的转换输入“整数"无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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