CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    May 2010
    Posts
    4

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

    I use Visual Basic 2010... and I got that problem (I'm a noob)... please help!
    I want to change the label's text when the progressbar hit the values

    Private Sub mainfrm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    If Timer1.Enabled = True Then
    Label3.Text("blah blah")
    End If
    If ProgressBar1.Value = 17 Then
    Label3.Text("blah blah")
    End If
    If ProgressBar1.Value = 25 Then
    Label3.Text("blah blah")
    End If
    If ProgressBar1.Value = 32 Then
    Label3.Text("blah blah")
    End If
    If ProgressBar1.Value = 44 Then
    Label3.Text("blah blah")
    End If
    End Sub
    End Class

  2. #2
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

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

    You could use Select Case
    Code:
    dim a as string
    Select Case Progressbar1.Value
      case 17: a="blah blah17"
      case 25: a="blah 25"
      '...
    End Select
    Label3.Text = a
    But sinye you say this is VB2010 you better put further questions in the VB.NET forum.
    We do VB6 here. In such basic stuff both languages are equal, but will differ as more complicated the stuff gets.

  3. #3
    Join Date
    May 2010
    Posts
    4

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

    Quote Originally Posted by WoF View Post
    You could use Select Case
    Code:
    dim a as string
    Select Case Progressbar1.Value
      case 17: a="blah blah17"
      case 25: a="blah 25"
      '...
    End Select
    Label3.Text = a
    But sinye you say this is VB2010 you better put further questions in the VB.NET forum.
    We do VB6 here. In such basic stuff both languages are equal, but will differ as more complicated the stuff gets.
    Thank you for the answer! I'll post new questions on VB.NET the next time...
    I've tried your code but it didn't work... when i debug the app the text doesn't change it doesn't display anything...

    another way to get it working?

  4. #4
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

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

    Well, you have put your code into mainfrm_Load() event. Why? It will only ever execute once and at this time ProgressBar1.Value would presumably be 0.

  5. #5
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

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

    yep.. if you want the labels to update as the progressbar changes then you would want to place that code in a timer or in a change event that is triggered by the progressbar. Also if the program is going to be busy make sure to issue a refresh for the label after you change the value or you may not see the values as they change.
    Always use [code][/code] tags when posting code.

  6. #6
    Join Date
    May 2010
    Posts
    4

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

    Quote Originally Posted by DataMiser View Post
    yep.. if you want the labels to update as the progressbar changes then you would want to place that code in a timer or in a change event that is triggered by the progressbar. Also if the program is going to be busy make sure to issue a refresh for the label after you change the value or you may not see the values as they change.
    I did it and now it works... but not as I would LOL

    He changes the label text but just when the progressbar hits the value 25 then the text disappear again... other ideas?

    Thank you guys

  7. #7
    Join Date
    May 2010
    Posts
    4

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

    Yep I solved!

    Dim a As String
    Select Case ProgressBar1.Value
    Case 17 To 24 : a = "blah blah17"
    Case 25 : a = "blah 25"
    '...
    End Select
    Label3.Text = a


    I must use to... thank you guys

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