Results 1 to 3 of 3

Thread: Controlling a progress bar.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2004
    Posts
    95

    Controlling a progress bar.

    How can I control a progress bar on my form from another class I created?

    For example, my main form calls a function in another class called SectionLister and in that class I have calls to other functions in another class called SubSectionLister. SectionLister figures out how many subsections it needs to parse using a hashtable with subsection URLs in it, and I want to be able to set the progress bar to the number of entries in the hashtable, then move the bar each time SubsectionLister.List is called with a value from the hashtable.

    So I tried to Dim progressbar as formMain.progressBar1 but I can't. What's the right way to do this?

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Pass the progressbar into the function as a parameter.

    VB Code:
    1. 'in class
    2. Dim _progressBar As ProgressBar
    3.  
    4. Public Sub DoSomething(ByVal progressBar As ProgressBar)
    5.    _progressBar=progressBar
    6.  
    7.    _progressBar.Value+=1
    8. End Sub
    9.  
    10. 'in calling form
    11. Dim t As New Test
    12. t.DoSomething(Me.ProgressBar1)

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Apr 2004
    Posts
    95
    You are the f***ing MAN! I had to pass it to a function that already took a parameter but I didn't realize I could pass it as an additional one.

    VB Code:
    1. ElseIf sectionSelected = 2 Then
    2.             gamesTable = sectionLister.List(gamesUrl, Me.mainBar)
    3.             gridMain.DataSource = gamesTable


    That works just fine. I also had to step the bar from within the for loop I have that iterates over the hashtable in the sectionLister.List function and that worked like a charm. I LOVE VB.NET!!!

    WOOHOO!

    Peace,
    KT

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