Flash Games
 FAQ   Search   Memberlist   Usergroups   Register  Profile   Log in to check your private messages   Log in 


Visual Basic Express - Help Needed



 

Post new topic   Reply to topic  
   DEVPPL Forum Index -> Visual Basic Forum
View previous topic :: View next topic  
Author Message
Rodney



Joined: 09 May 2008
Posts: 1

PostPosted: Fri May 09, 2008 11:09 am    Post subject: Visual Basic Express - Help Needed Reply with quote

Hi All

I am trying to create a program that eventually will backup data, my biggest challenge is that the progress bar runs when "previewing".
I would like to add a button "start" and connect the progress bar to execute when "start" is clicked.
I also would like the cancell button to close the entire program... sigh*


Any input will be appreciated !! Idea





Public Class Form1

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing


End Sub


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Me.BackgroundWorker1.RunWorkerAsync()

ProgressBar1.Style = ProgressBarStyle.Continuous = 10000

ProgressBar1.Dock = DockStyle.Bottom

ProgressBar1.Visible = True

ProgressBar1.Minimum = 1

ProgressBar1.Maximum = 100

BackgroundWorker1.WorkerReportsProgress = True

BackgroundWorker1.WorkerSupportsCancellation = True

End Sub


Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork

Dim i As Integer = 0

While (Not Me.BackgroundWorker1.CancellationPending) And i <= 99

i = i + 1

System.Threading.Thread.Sleep(200)

Me.BackgroundWorker1.ReportProgress(i) ' file processing here

End While

If (Me.BackgroundWorker1.CancellationPending) Then

e.Cancel = True


Else

End If

e.Result = "BACKUP COMPLETED"


End Sub


Private Sub BackgroundWorker1_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged

ProgressBar1.Visible = True

ProgressBar1.Value = e.ProgressPercentage

End Sub

Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted

ProgressBar1.Visible = False

If (e.Error IsNot Nothing) Then

MessageBox.Show(e.Error.Message)

ElseIf e.Cancelled Then

MessageBox.Show("Canceled")

Else

End If

MessageBox.Show(e.Result.ToString)
If (e.Cancelled = True) Then

End If


End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Me.BackgroundWorker1.CancelAsync()

End Sub
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    DEVPPL Forum Index -> Visual Basic Forum All times are GMT + 1 Hour
Page 1 of 1

 
 
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums.
Click here to Register

If you are a current member here on DEVPPL, please login below:

User: Pass:
Log me on automatically each visit:

 


Powered by phpBB © 2001, 2005 phpBB Group - Modified by DEVPPL

Flash Games - Sitemap