Solved

VB 2008 VB.NET Display Animation

Posted on 2009-06-30
8
466 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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 …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

929 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now