none
BC30545 Visual Basic AND VB.NET Property access must assign to the property or use its value. RRS feed

  • Question

  •         My.Settings.Username = TextBox1.Text
            My.Settings.Password = TextBox2.Text
            My.Settings.Save()

    In My.Settings.Save i have an error

    " Property access must assign to the property or use its value. "

    Someone can help?

    Saturday, October 20, 2018 11:02 AM

All replies

  • Hello,

    Can you please check once with the code below

    Try
                My.MySettings.Default.Username = TextBox1.Text
                My.MySettings.Default.Password = TextBox2.Text
                My.Settings.Save()
            Catch ex As Exception
                Dim errormsg As String = String.Empty
                errormsg = ex.ToString()
            End Try

    • Marked as answer by floyare Saturday, October 20, 2018 11:37 AM
    • Unmarked as answer by floyare Saturday, October 20, 2018 11:37 AM
    Saturday, October 20, 2018 11:28 AM
  • Hello,

    Can you please check once with the code below

    Try
                My.MySettings.Default.Username = TextBox1.Text
                My.MySettings.Default.Password = TextBox2.Text
                My.Settings.Save()
            Catch ex As Exception
                Dim errormsg As String = String.Empty
                errormsg = ex.ToString()
            End Try

    I can't debug this

    Because there is still an error


    • Edited by floyare Saturday, October 20, 2018 11:41 AM
    Saturday, October 20, 2018 11:40 AM
  • OK Strange Actually same code working well at my place. Unable to recreate the issue. Let me check again
    Saturday, October 20, 2018 11:45 AM
  • OK, the error was solved it was my fault because I had in the settings included the setting called "Save" and that's why it made mistakes. Thanks for help :)
    • Proposed as answer by tommytwotrain Sunday, October 21, 2018 1:45 PM
    Saturday, October 20, 2018 11:55 AM
  • Ok great...good finding
    Saturday, October 20, 2018 12:00 PM
  • hello,

    I think that Save is not a method, because in the message it is explicitly indicated that a property access must assign to it or use its value, then for the compiler Save is a property and not a method, try this:

    // .......
    //the name Save give the impression of a method, but the compiler 
    // complains about it and suggest to assign a value or access it,
    // maybe .Save is not a method but a property
    MySettings.Save = true;

    Good Coding;

    Saturday, October 20, 2018 3:01 PM
  • hello,

    I think that Save is not a method, because in the message it is explicitly indicated that a property access must assign to it or use its value, then for the compiler Save is a property and not a method, try this:

    // .......
    //the name Save give the impression of a method, but the compiler 
    // complains about it and suggest to assign a value or access it,
    // maybe .Save is not a method but a property
    MySettings.Save = true;

    Good Coding;


    Yes, very good. LOL.

    PS in other words vb assumed save was a variable because it was declared that way and gave the error as it should.

    Perhaps option strict or explicit would/should/did show error on that line?


    Sunday, October 21, 2018 1:44 PM
  • yup, 

    happy to help :)

    Good Coding;

    Sunday, October 21, 2018 1:50 PM
  • Hi ,

    Do you resolve the issue? If you resolve the issue, could you please mark the helpful as answer. It will be beneficial to other community.

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, October 23, 2018 7:11 AM