“整数”类型的值无法转换为“system.windows.forms.textbox” [英] value of type 'integer' cannot be converted to 'system.windows.forms.textbox'

查看:75
本文介绍了“整数”类型的值无法转换为“system.windows.forms.textbox”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将datagridview的单元格值移动到文本框数组中。代码是这样的。

I am trying to move value of cells of a datagridview to an array of textboxes. The code is like this.

For i = 1 To 11
   mAmt = (dgActuals.Rows(xRow).Cells(xColumn).Value)
   If Not mAmt = 0 Then
      txtFigure(i, 0).Text = mAmt
      xColumn += 1
   End If
Next i



运行时显示Nullreferenceexception未处理

对象引用未设置为对象的实例。



可以请任何身体帮助。



Tanveer


When run it shows that Nullreferenceexception was unhandled
Object reference not set to an instance of an object.

Could any body help please.

Tanveer

推荐答案

你总是需要提供全面的错误我信息,首先 - 显示代码行并指出错误来源的位置。最有可能的是,您尝试将整数值分配给类 TextBox 的实例。您应该分配 MyTextBox.Text = mAmt.ToString(...)。可能, txtFigure(i,0).Text 的类型为 TextBox ...



在真正继续之前,你真的需要学习一般的编程基础知识和特别是OOP。学习类型和对象/实例,类及其成员,静态和实例成员,.NET类型系统,装箱,参考和值类型等。



-SA
You always need to provide comprehensive error information, first of all — show the line of the code and indicate where is the source of the error. Most likely, you tried to assign integer value to the instance of the class TextBox. You should assign MyTextBox.Text = mAmt.ToString(...). Probably, txtFigure(i, 0).Text has the type of TextBox

You really need to learn very basics of programming in general and OOP in particular before you can really continue. Learn types and objects/instances, classes and their members, static and instance members, .NET type system, boxing, reference vs value types, etc.

—SA


我设法找到问题的解决方案,你在回答查询时不必那么强烈。
I have managed to find solution to my problem and you do not have to be so AGGRESSIVE while answering queries.


这篇关于“整数”类型的值无法转换为“system.windows.forms.textbox”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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