Solved

VB 2008 VB.NET Display Animation

Posted on 2009-06-30
8
479 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

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 was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

691 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