Solved

VB 2008 VB.NET Display Animation

Posted on 2009-06-30
8
464 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

758 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

21 Experts available now in Live!

Get 1:1 Help Now