vb.net 错误:属性访问必须分配给属性或使用其值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13591678/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error with: Property Access Must Assign To The Property Or Use Its Value
提问by Shah_Clique
recently i have been assigned a homework task to create any program i like with the use of polymorphism, inheritance etc so ive gotten pretty far with my application but ive come across an error which says :
最近,我被分配了一项家庭作业来使用多态、继承等创建我喜欢的任何程序,所以我的应用程序已经走得很远了,但我遇到了一个错误,它说:
Property Access Must Assign To The Property Or Use Its Value.
属性访问必须分配给属性或使用其值。
I personally have no idea what that means and ive attached some of my code where the error is constructing:
我个人不知道这意味着什么,我附上了一些错误构建的代码:
If rdbRed.Checked And rdbChequredBlack.Checked And rdbVision.Checked And rdbTinted.Checked Then
MiniCooperS.GetTotalCarPrice(MiniColour, MiniInterior, MiniPackages, MiniWindows)
Elseif...
so the error is showing somewhere within this code and ive been at it for hours and cant seem to figure it out.. Help is appreciated!!
所以错误显示在这段代码中的某个地方,我已经研究了几个小时,但似乎无法弄清楚。感谢帮助!
THANKS!
谢谢!
回答by jpauley
If your getTotalCarPrice()function returns a value (I'm assuming it returns an int or a String), you must assign that value to a variable. ie.
如果您的getTotalCarPrice()函数返回一个值(我假设它返回一个 int 或一个 String),您必须将该值分配给一个变量。IE。
dim carPrice As Integer
If rdbRed.Checked And rdbChequredBlack.Checked And rdbVision.Checked And rdbTinted.Checked Then
carPrice = MiniCooperS.GetTotalCarPrice(MiniColour, MiniInterior, MiniPackages, MiniWindows)
Elseif...
Else carPrice = 0

