VB 2010涵盖错误 [英] vb 2010 covering error

查看:87
本文介绍了VB 2010涵盖错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码

this is my code

Dim ok As Integer
Dim kk As Integer
Dim ik As Integer
Private Sub cb1_TextChanged(sender As System.Object, e As System.EventArgs) Handles cb1.TextChanged
    ok = Convert.ToInt32(cb1.Text)
    ok = CInt(cb1.Text)
    kk = Convert.ToInt32(cb2.Text)
    kk = CInt(cb2.Text)
    ik = Convert.ToInt32(cb3.Text)
    ik = CInt(cb3.Text)
end sub



这是我的错误

Input string was not in a correct format.
当我在组合框中更改数字时会收到错误消息,cb1 = combobox1



and this is my error

Input string was not in a correct format.
I get the error when I change a number i the combobox, cb1 = combobox1

推荐答案

这将取决于您的数据-即用户类型如何.
如果您只想要一个数字,为​​什么不使用NumericUpDown-它们甚至可以应用上限和下限.

或者,使用 Int32.TryParse [
That is going to depend on your data - i.e. whatever the user types.
If you just want a number, why not use a NumericUpDown - they can even apply upper and lower limits.

Alternatively, use the Int32.TryParse[^] method instead?


这篇关于VB 2010涵盖错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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