|
-
December 1st, 2004, 09:14 PM
#1
Property access must assign to the property or use its value.
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
-
December 2nd, 2004, 06:39 AM
#2
Re: Property access must assign to the property or use its value.
Zip up your project and post it.
Good Luck,
Craig - CRG IT Solutions - Microsoft Gold Partner
-My posts after 08/2015 = .NET 4.x and Visual Studio 2015
-My posts after 11/2011 = .NET 4.x and Visual Studio 2012
-My posts after 02/2010 = .NET 4.0 and Visual Studio 2010
-My posts after 12/2007 = .NET 3.5 and Visual Studio 2008
-My posts after 04/2007 = .NET 3.0 and Visual Studio 2005
-My posts before 04/2007 = .NET 1.1/2.0
*I do not follow all threads, so if you have a secondary question, message me.
-
December 2nd, 2004, 07:11 AM
#3
Re: Property access must assign to the property or use its value.
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()
If you think you CAN, you can, If you think you CAN'T, you are probably right.
Have some nice Idea to share? Write an Article Online or Email to us and You may WIN a Technical Book from CG.
-
December 2nd, 2004, 03:55 PM
#4
Re: Property access must assign to the property or use its value.
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
-
December 3rd, 2004, 07:54 AM
#5
Re: Property access must assign to the property or use its value.
And assigning (then not using) a value to a local ByVal parameter is supposed to do what??????
-
December 3rd, 2004, 09:47 AM
#6
Re: Property access must assign to the property or use its value.
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 ....
Code:
Sub MyCancelButton()
...
Hope it helps
Last edited by DeepButi; December 3rd, 2004 at 09:55 AM.
Did it help? rate it.
The best conversation I had was over forty million years ago ... and that was with a coffee machine.
-
December 3rd, 2004, 03:42 PM
#7
Re: Property access must assign to the property or use its value.
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|