用于将字符串转换为Label时控制错误 [英] Controls error when using to convert string to Label

查看:73
本文介绍了用于将字符串转换为Label时控制错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在vs2008中的windows mobile 6中写了一个vb appl



我写了一些代码如下:



lblfld(1)=lbl_field_1

bllfld(2)=lbl_field_2



lblfld_show(1)=Part不。

lblfld_show(2)=客户批号



和lbl_field_1是标签格式



此应用程序运行此语句时,

Panel_Main.Controls(lblfld(y))。Text = lblfld_show(y)



它总是会产生InvalidCastExceptionunhandled错误: -

从字符串lbl_field_1转换为''整数''是无效。



任何人都可以向我提出解决方案。谢谢

I write a vb appl in window mobile 6 in vs2008

I write some code as follow :

lblfld(1) = "lbl_field_1"
bllfld(2) = "lbl_field_2"

lblfld_show(1) = "Part No."
lblfld_show(2) = "Client Lot No."

And "lbl_field_1" is Label in the form

when this app run to this statment,
Panel_Main.Controls(lblfld(y)).Text = lblfld_show(y)

It always incur an InvalidCastExceptionunhandled error as :-
"Conversion from string "lbl_field_1" to type ''Integer'' is not valid."

Can anyone metion a solution to me. Thanks

推荐答案

你真的需要在VB.NET上获取一本初学者书并完成它。您不能将字符串分配给需要数字的属性。您也不能将控件的名称用作数字,即使您没有真正这样做,看起来好像您认为这样可行。
You REALLY need to pickup a beginners book on VB.NET and work through it. You cannot assign a string to a property that expects a number. You also cannot use the name of a control as a number, even though you didn''t really do that, it appears as though you think that will work.


这篇关于用于将字符串转换为Label时控制错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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