CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2004
    Location
    North Idaho
    Posts
    18

    Angry 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

  2. #2
    Join Date
    Feb 2000
    Location
    OH - USA
    Posts
    1,892

    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.

  3. #3
    Andy Tacker is offline More than "Just Another Member"
    Join Date
    Jun 2001
    Location
    55°50' N 37°39' E
    Posts
    1,503

    Exclamation 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.

  4. #4
    Join Date
    Nov 2004
    Location
    North Idaho
    Posts
    18

    Lightbulb 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

  5. #5
    Join Date
    Oct 2004
    Posts
    78

    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??????

  6. #6
    Join Date
    Dec 2003
    Location
    St. Cugat - Catalunya
    Posts
    441

    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.

  7. #7
    Join Date
    Nov 2004
    Location
    North Idaho
    Posts
    18

    Talking 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
  •  





Click Here to Expand Forum to Full Width

Featured