VB程序lable

来源:百度知道 编辑:UC知道 时间:2024/05/25 05:52:50
怎么把 label1 和 label2 的值 相加呀? 我说的是label1和label2他们显示的数字 就是把数字相加!

Label1和2的Caption属性就是它所显示的“数字”,不过是文本形式,要相加就先转成数值型。

结果=Val(Label1.Caption)+Val(Label2.Caption)

是Caption属性,不是Text,Label没有Text属性,除非是在.NET

假定我们再放一个label3用来显示相加后的结果。
只需在command1的代码中加入
Label3.Text=Val(Label1.Text)+Val(Label2.Text)就行了,不信你试试看!