Results 1 to 15 of 15

Thread: Accessing Controls from a different class....

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2011
    Location
    Seattle
    Posts
    218

    Accessing Controls from a different class....

    Alright I have 3 forms - The load up form "QoE" and two public classes. I also have an progress bar on the main form "QoE." Ive been able to access controls in other classes in numerous other projects, but for some reason this project is giving me fits. I have no idea why I can not control the progress bar from my class "Utils."

    The classes kind of look like this:

    Code:
    Public Class QoE
    End Class
    
    Public Class Utils
        public shared sub ProgressBar
            Dim f1 as New QoE()
            f1.ProgressBarMain.Increment(+1)
            f1.ProgressPercent.Text = f1.ProgressBarMain.Value.ToString() & "%"
        end sub 
    End Class
    
    Public Class Tests
        public shared sub DoWork
            Utils.Progressbar()
        End Sub 
    End Class

    Now, I was always under the impression that I could simply just call the controls like this:

    QoE.ProgressBarMain.Increment(+1)

    I actually have other projects where i did this, but now I am getting the error - "reference to a non shared member requires an object reference."

    So Ive been tinkering with the above code because I have seen other people do it around the net. I don't receive an error, but it is also not doing anything.

    I have all the controls set to public of course, so why is this not working?

    Thanks Guys

    Edit* I went back through my old projects and I definitely have called form1 controls before using something like form1.listbox.add() from form2. I cant figure out what is different though between that project and this project.
    Last edited by Zmcpherson; Oct 23rd, 2013 at 07:47 PM.

Tags for this Thread

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