Solved

VB 2008 VB.NET Display Animation

Posted on 2009-06-30
8
468 Views
Last Modified: 2013-11-05
Hi,
  I like to have an animation that runs when the program is searching for data, something that shows user that it is functioning.  I do not know how long it will take, so I need something just keeps running.  
   Any one can give me some direction?  

Thanks!
0
Comment
Question by:KC1688
  • 4
  • 2
8 Comments
 
LVL 14

Expert Comment

by:shahprabal
ID: 24748312
check out :
http://msdn.microsoft.com/en-us/library/system.windows.forms.progressbar.aspx

Private Sub CopyWithProgress(ByVal ParamArray filenames As String())
    ' Display the ProgressBar control.
    pBar1.Visible = True
    ' Set Minimum to 1 to represent the first file being copied.
    pBar1.Minimum = 1
    ' Set Maximum to the total number of files to copy.
    pBar1.Maximum = filenames.Length
    ' Set the initial value of the ProgressBar.
    pBar1.Value = 1
    ' Set the Step property to a value of 1 to represent each file being copied.
    pBar1.Step = 1
 
    ' Loop through all files to copy.
    Dim x As Integer
    for x = 1 To filenames.Length - 1
        ' Copy the file and increment the ProgressBar if successful.
        If CopyFile(filenames(x - 1)) = True Then
            ' Perform the increment on the ProgressBar.
            pBar1.PerformStep()
        End If
    Next x
End Sub

Open in new window

0
 
LVL 14

Expert Comment

by:shahprabal
ID: 24748353
Also check out :
http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/035b622b-2751-4266-99bb-2aa41a3ed6ea
If you want to use the example in the above link you can convert it to vb.net here :
http://www.developerfusion.com/tools/convert/csharp-to-vb/
 
0
 

Author Comment

by:KC1688
ID: 24749439
Thanks!  

I tried the progress bar & timer without gathering the data and it worked.  

When the application is getting data, the progress bar and text box become transpart and can not see progress bar moving.  

Please help!!!
0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 14

Expert Comment

by:shahprabal
ID: 24750404
I think your form is becoming unresponsive... need to use something like this :
http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx
to run the method that gets the data. If you need help with the code post your code.
0
 
LVL 27

Expert Comment

by:VBRocks
ID: 24755071
You can also just set your ProgressBar.Style to Marquee, if you're not able to calculate the progress.

0
 

Author Comment

by:KC1688
ID: 24767723
Hi,

  I was hoping I could get it myself, but the ProgressBar Window is still hanging.

  Here is what I like my app to do:
  FormGettingData btnGetData_Click ---> FromGettingData.Enabled = false
  FormProgressBar.show ----> Show ProgressBar running, no need to calculate progress
  Then FormProgressBar go away
  Then FormGettingData  show again
  One additional window FormDoGraph show
 
  I have the following code in the form that tries to get data and I did not post 'get data' code.  I don't know if it affects the whole thing...  Also, my FormDoGraph after the calculation is still haning, not able to display Graph....

Thanks lot lot!


 Private Sub GetData(ByVal worker As BackgroundWorker, ByVal e As DoWorkEventArgs)

        If worker.CancellationPending Then
            e.Cancel = True
        Else

           'Caculations/getting data here
  End Sub


    Private Sub backgroundWorker1_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        Dim worker As BackgroundWorker = CType(sender, BackgroundWorker)
        GetImpData(worker, e)

        If worker.CancellationPending Then
            e.Cancel = True
        End If
    End Sub

    Private Sub backgroundWorker1_RunWorkCompleted(ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted

        If e.Cancelled Then
            MessageBox.Show("Operation was cancelled")
        ElseIf (e.Error IsNot Nothing) Then
            Dim msg As String = String.Format("An error occurred: {0}", e.Error.Message)
            MessageBox.Show(msg)
        Else
            MessageBox.Show("Operaton was completed")
        End If
    End Sub



    Private Sub btnGetData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetImp.Click
        MeasuringProgressBar.Show()
     

        BackgroundWorker1.RunWorkerAsync()

        Me.Enabled = False


        MeasuringProgressBar.Close()
        Me.Enabled = True
    End Sub
0
 
LVL 14

Accepted Solution

by:
shahprabal earned 500 total points
ID: 24787128
Couple of things :
1) After BackgroundWorker1.RunWorkerAsync() the execution of that thread continues, so MeasuringProgressBar.Close will be called before the work is completed. You should move it to RunWorkerCompleted event.
2) I think the main problem could be here :            'Caculations/getting data here
When you are running a separate thread but you try to access the form's control, you need to do it in a specific way. I had trouble understanding it and Chaosian explained it perfectly here :
http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_22494712.html
 
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question