Click to See Complete Forum and Search --> : Property access must assign to the property or use its value.


4461766964
December 1st, 2004, 08:14 PM
Error: Property access must assign to the property or use its value.

This one is killing me. This is a upgrade problem from VB6 to .NET. I have several forms calling this code located inside a module. It provides that if someone hits Cancel on any of the available forms, it will do the same thing... Which is prompt for confirmation and then exit the application. The call from the forms is:

--
Call CancelButton()
--

The Module code is as follows:

-------------------------------------
Public Sub CancelButton()
'Prompts for confirmation of premature Cancel/Close/Exit of program by button and menu and closes on Yes.

Dim intExitResult As Short

intExitResult = MsgBox("Warning: This action will cancel your update and close this program." & vbCrLf & "The files on your hard drive will not be updated. Are you sure?", MsgBoxStyle.YesNo + MsgBoxStyle.Question + MsgBoxStyle.DefaultButton2, "Exit the program?")

If intExitResult = MsgBoxResult.Yes Then
Call ErrorLog() 'Just logs the cancel in a file. Also in this module.
Call UniversalExit() 'Closes all forms and exits. Also in this module.
Else
'Just continue un-closed, leaving off where user was...
End If
End Sub
-------------------------------------

Any help would be much appreciated!! Thanks.

Dave

Craig Gemmill
December 2nd, 2004, 05:39 AM
Zip up your project and post it.

Andy Tacker
December 2nd, 2004, 06:11 AM
now, where is the problem???

did you include this function in separate class?

using namespace xXxYyY
class CommonFunctions
Public Sub CancelButton(){}

now you can access this function by using xXxYyY.CommonFunctions.CancelButton()

4461766964
December 2nd, 2004, 02:55 PM
Thanks for the help. I tried that and it made things worse, because it seems I still don't understand. However, I have figured out that I may have been barking up the wrong tree yet. I thought it was the procedure causing the error. When I played with the call it removed the complaint from the task list tho'.

--
Public Sub mnuFileExit_Click(ByVal eventSender As System.Object, _
ByVal eventArgs As System.EventArgs) Handles mnuFileExit.Click
'Calls the prompted exit.

eventSender = CancelButton()
End Sub
--

Both lines eventSender =, or eventArgs =, seem to work. I don't know if this is proper procedure, or if it will work, but it does seem to stop complaining at least. Now to see if it will compile! :-)

Thanks again.

Dave

AnotherAlias
December 3rd, 2004, 06:54 AM
And assigning (then not using) a value to a local ByVal parameter is supposed to do what??????

DeepButi
December 3rd, 2004, 08:47 AM
4461766964,
CancelButton is a property, so you cannot use it as a name in your function. Simply stay with your first post BUT use any other name ....
Sub MyCancelButton()
...
Hope it helps

4461766964
December 3rd, 2004, 02:42 PM
Hot dog, that was it! Thank you DeepButi! Such a simple, stupid problem. I'll have to keep my eye on those new property names... Now that I understand why the error was coming up, the "Property access" message makes perfect sense. Yeesh. Thanks again!!

Dave