Codice PHP:
Imports System.Net
Imports System
.IO
Imports System
.ComponentModel

Public Class MainForm
    Dim RomName 
As String
    Dim CleanRomName 
As String
    Dim WebClient 
As New WebClient
    Dim DestRomName 
As String
    Dim log 
As String
    Dim prgss 
As Integer
    
Private Sub BWorker_DoWork(ByVal sender As System.ObjectByVal e As System.ComponentModel.DoWorkEventArgsHandles BWorker.DoWork
        
For As Integer 0 To 100
            Dim 
Array() As Byte IO.File.ReadAllBytes(RomName)
            If Array(
8) = 66 AndAlso Array(9) = 50 Then
                WebClient
.DownloadFile("URL""b2.xdelta")
                
Dim B2Patch As String Directory.GetCurrentDirectory "\b2.xdelta"
                
Dim str As String String.Empty
                
str String.Concat(New String() { _
                                    str
" patch """B2Patch""" """RomName""" """DestRomName""""_
                                
)
                
Dim prcss As New Process
                prcss
.StartInfo.Arguments str
                prcss
.StartInfo.FileName "xdelta.exe"
                
prcss.StartInfo.UseShellExecute False
                prcss
.StartInfo.CreateNoWindow True
                prcss
.StartInfo.RedirectStandardError True
                prcss
.Start()
                
prcss.WaitForExit()
                
BlackCheck()
                
BWorker.ReportProgress(i)
            Else : Array(
8) = 87 AndAlso Array(9) = 50
                WebClient
.DownloadFile("URL""w2.xdelta")
                
Dim W2Patch As String Directory.GetCurrentDirectory "\w2.xdelta"
                
Dim str As String String.Empty
                
str String.Concat(New String() {str" patch """W2Patch""" """RomName""" """DestRomName""""_
                                
)
                
Dim prcss As New Process
                prcss
.StartInfo.Arguments str
                prcss
.StartInfo.FileName "xdelta.exe"
                
prcss.StartInfo.UseShellExecute False
                prcss
.StartInfo.CreateNoWindow True
                prcss
.StartInfo.RedirectStandardError True
                prcss
.Start()
                
prcss.WaitForExit()
                
WhiteCheck()
                
log prcss.StandardError.ReadToEnd
                BWorker
.ReportProgress(i)
            
End If
        
Next
    End Sub

    
Private Sub btn_Patcher_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles btn_Patcher.Click
        Dim ofd 
As New OpenFileDialog()
        
Dim sfd As New SaveFileDialog()
        
ofd.Filter "Applicazione(*.exe)|*.exe"
        
ofd.Title "Scegli il file da patchare."
        
ofd.ShowDialog()
        
sfd.Filter "Applicazione(*.exe)|*.exe"
        
sfd.Title "Scegli dove e con quale nome sarà il file."
        
sfd.ShowDialog()
        If 
ofd.FileName <> "" And sfd.FileName <> "" Then
            DestRomName 
sfd.FileName
            RomName 
ofd.FileName
            CleanRomName 
ofd.SafeFileName
            BWorker
.RunWorkerAsync()
            
btn_Cancel.Enabled True
        
Else : MessageBox.Show("Selezionare tutte e due i file, di origine e di destinazione, per poter continuare""Attenzione!"MessageBoxButtons.OKMessageBoxIcon.Exclamation)
        
End If
    
End Sub

    
Private Sub BWorker_ProgressChanged(ByVal sender As ObjectByVal e As ProgressChangedEventArgsHandles BWorker.ProgressChanged
        ProgressBar1
.Value e.ProgressPercentage
    End Sub

    
Public Sub BlackCheck()
        If (
log ""Then
            MessageBox
.Show("Programma 1 patchato con successo!")
        Else
            
MessageBox.Show(log)
        
End If
    
End Sub

    
Public Sub WhiteCheck()
        If (
log ""Then
            MessageBox
.Show("Programma 2 patchato con successo!")
        Else
            
MessageBox.Show(log)
        
End If
    
End Sub

    
Private Sub btn_Cancel_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles btn_Cancel.Click
        Dim risposta 
As MsgBoxResult
        risposta 
MessageBox.Show("Annullare l'operazione corrente?" Chr(13) + _
                        
"Annullando l'operazione corrente, tutti i dati fin'ora scritti saranno inutilizzabili, eccetto il file madre, che rimarrà inalterato."_
                        
"Attenzione!"_
                        MessageBoxButtons
.OKCancel_
                        MessageBoxIcon
.Exclamation_
                        MessageBoxDefaultButton
.Button2)
        If 
risposta MsgBoxResult.Ok Then BWorker.CancelAsync() Else 
    
End Sub

    
Private Sub MainForm_Load(ByVal sender As System.ObjectByVal e As System.EventArgsHandles MyBase.Load
        Dim percent 
As Integer CInt(Math.Truncate((CDbl(ProgressBar1.Value) / CDbl(ProgressBar1.Maximum)) * 100))
        
ProgressBar1.CreateGraphics().DrawString(percent.ToString() & "%", New Font("Arial"CSng(8.25), FontStyle.Regular), Brushes.Black, New PointF(ProgressBar1.Width 10ProgressBar1.Height 7))
    
End Sub
End 
Class 
Il mio problema è che: prima di tutto non riesco a mettere la percentuale sovraimpressa alla ProgressBar, e poi non so perché non mi funziona la progressbar stessa. Vorrei che la percentuale di completamento sia corrispondete a quella dello stato di completamento dell'operazione in background. Grazie