首页 > 解决方案 > Value of type 'String' cannot be converted to System.Windows.Forms.Label

问题描述

I'm a bit of a noob. When I try to build my solution I get this single error and I don't know what to do to fix it.

 'Calculate and display cost estimate
                decCostEstimate = decFeet * decCostPerFoot
                **lblCostEstimate = decCostEstimate.ToString("C")**

I'm not sure what to do. Please help me.

标签: stringvb.net

解决方案


标签是 type 中的一个对象 Label。无法将 Typeintstring等中的对象写入标签对象。

要使标签显示您的结果,只需将结果放入标签的文本属性中:

lblCostEstimate.Text = decCostEstimate.ToString("C")


推荐阅读