I have translated the whole c# code for you to vb.net, (see bottom for
the problem):
We need someone to help us with it.
Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports RJH.Utils.WebDownload
Public Class WebDownloadForm
Inherits System.Windows.Forms.Form
Private downloadUrlTextBox As System.Windows.Forms.TextBox
Private urlLabel As System.Windows.Forms.Label
Private outputGroupBox As System.Windows.Forms.GroupBox
Private downloadBtn As System.Windows.Forms.Button
Private downloadProgressLbl As System.Windows.Forms.Label
Private bytesDownloadedLbl As System.Windows.Forms.Label
Private totalBytesLbl As System.Windows.Forms.Label
Private bytesDownloadedTextBox As
System.Windows.Forms.TextBox
Private totalBytesTextBox As System.Windows.Forms.TextBox
Private progressBar As System.Windows.Forms.ProgressBar
Private components As System.ComponentModel.Container =
Nothing
Public Sub New()
InitializeComponent()
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing
As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Private Sub InitializeComponent()
Me.downloadUrlTextBox = New System.Windows.Forms.TextBox
Me.urlLabel = New System.Windows.Forms.Label
Me.outputGroupBox = New System.Windows.Forms.GroupBox
Me.downloadBtn = New System.Windows.Forms.Button
Me.progressBar = New System.Windows.Forms.ProgressBar
Me.downloadProgressLbl = New System.Windows.Forms.Label
Me.bytesDownloadedLbl = New System.Windows.Forms.Label
Me.totalBytesLbl = New System.Windows.Forms.Label
Me.bytesDownloadedTextBox = New
System.Windows.Forms.TextBox
Me.totalBytesTextBox = New System.Windows.Forms.TextBox
Me.outputGroupBox.SuspendLayout()
Me.SuspendLayout()
Me.downloadUrlTextBox.Location = New
System.Drawing.Point(128, 16)
Me.downloadUrlTextBox.Name =
"downloadUrlTextBox"
Me.downloadUrlTextBox.Size = New
System.Drawing.Size(280, 20)
Me.downloadUrlTextBox.TabIndex = 0
Me.downloadUrlTextBox.Text = ""
Me.urlLabel.Location = New System.Drawing.Point(16,
20)
Me.urlLabel.Name = "urlLabel"
Me.urlLabel.Size = New System.Drawing.Size(100,
16)
Me.urlLabel.TabIndex = 1
Me.urlLabel.Text = "File To Download :"
Me.outputGroupBox.Controls.AddRange(New
System.Windows.Forms.Control() {Me.totalBytesTextBox,
Me.bytesDownloadedTextBox, Me.bytesDownloadedLbl,
Me.downloadProgressLbl, Me.progressBar, Me.totalBytesLbl})
Me.outputGroupBox.Enabled = False
Me.outputGroupBox.Location = New
System.Drawing.Point(8, 48)
Me.outputGroupBox.Name = "outputGroupBox"
Me.outputGroupBox.Size = New System.Drawing.Size(504,
120)
Me.outputGroupBox.TabIndex = 2
Me.outputGroupBox.TabStop = False
Me.outputGroupBox.Text = "Output and Callbacks"
Me.downloadBtn.Location = New
System.Drawing.Point(416, 16)
Me.downloadBtn.Name = "downloadBtn"
Me.downloadBtn.Size = New System.Drawing.Size(88,
23)
Me.downloadBtn.TabIndex = 3
Me.downloadBtn.Text = "Download"
AddHandler Me.downloadBtn.Click, AddressOf
Me.downloadBtn_Click
Me.progressBar.Location = New
System.Drawing.Point(120, 88)
Me.progressBar.Name = "progressBar"
Me.progressBar.Size = New System.Drawing.Size(376,
23)
Me.progressBar.TabIndex = 0
Me.downloadProgressLbl.Location = New
System.Drawing.Point(16, 88)
Me.downloadProgressLbl.Name =
"downloadProgressLbl"
Me.downloadProgressLbl.Size = New
System.Drawing.Size(104, 23)
Me.downloadProgressLbl.TabIndex = 1
Me.downloadProgressLbl.Text = "Download
Progress"
Me.bytesDownloadedLbl.Location = New
System.Drawing.Point(16, 28)
Me.bytesDownloadedLbl.Name =
"bytesDownloadedLbl"
Me.bytesDownloadedLbl.TabIndex = 2
Me.bytesDownloadedLbl.Text = "Bytes Downloaded"
Me.totalBytesLbl.Location = New
System.Drawing.Point(16, 60)
Me.totalBytesLbl.Name = "totalBytesLbl"
Me.totalBytesLbl.TabIndex = 2
Me.totalBytesLbl.Text = "Total Bytes"
Me.bytesDownloadedTextBox.Location = New
System.Drawing.Point(120, 24)
Me.bytesDownloadedTextBox.Name =
"bytesDownloadedTextBox"
Me.bytesDownloadedTextBox.ReadOnly = True
Me.bytesDownloadedTextBox.Size = New
System.Drawing.Size(168, 20)
Me.bytesDownloadedTextBox.TabIndex = 3
Me.bytesDownloadedTextBox.Text = ""
Me.bytesDownloadedTextBox.TextAlign =
System.Windows.Forms.HorizontalAlignment.Center
Me.totalBytesTextBox.Location = New
System.Drawing.Point(120, 56)
Me.totalBytesTextBox.Name = "totalBytesTextBox"
Me.totalBytesTextBox.ReadOnly = True
Me.totalBytesTextBox.Size = New
System.Drawing.Size(168, 20)
Me.totalBytesTextBox.TabIndex = 4
Me.totalBytesTextBox.Text = ""
Me.totalBytesTextBox.TextAlign =
System.Windows.Forms.HorizontalAlignment.Center
Me.AutoScaleBaseSize = New System.Drawing.Size(5,
13)
Me.ClientSize = New System.Drawing.Size(520, 175)
Me.Controls.AddRange(New
System.Windows.Forms.Control() {Me.downloadBtn,
Me.outputGroupBox, Me.urlLabel, Me.downloadUrlTextBox})
Me.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.FixedDialog
Me.Name = "WebDownloadForm"
Me.Text = "WebDownload Tester"
Me.outputGroupBox.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
<STAThread()> _
Shared Sub Main()
Application.Run(New WebDownloadForm)
End Sub
Private Sub DownloadProgressCallback(ByVal bytesSoFar As
Integer, ByVal totalBytes As Integer)
bytesDownloadedTextBox.Text =
bytesSoFar.ToString("#,##0")
If Not (totalBytes = -1) Then
progressBar.Minimum = 0
progressBar.Maximum = totalBytes
progressBar.Value = bytesSoFar
totalBytesTextBox.Text =
totalBytes.ToString("#,##0")
Else
progressBar.Visible = False
totalBytesTextBox.Text = "Total File Size Not
Known"
End If
End Sub
Private Sub DownloadCompleteCallback(ByVal dataDownloaded
As Byte())
If Not progressBar.Visible Then
progressBar.Visible = True
progressBar.Minimum = 0
progressBar.Value = progressBar.Maximum = 1
totalBytesTextBox.Text = bytesDownloadedTextBox.Text
End If
MessageBox.Show("Download complete...",
"Download Info")
End Sub
Private Sub downloadBtn_Click(ByVal sender As Object,
ByVal e As System.EventArgs)
If Not (Me.downloadUrlTextBox.Text = "")
Then
Me.outputGroupBox.Enabled = True
Me.bytesDownloadedTextBox.Text = ""
Me.totalBytesTextBox.Text = ""
Me.progressBar.Minimum = 0
Me.progressBar.Maximum = 0
Me.progressBar.Value = 0
Dim dl As DownloadThread = New DownloadThread
dl.DownloadUrl = Me.downloadUrlTextBox.Text
AddHandler dl.CompleteCallback, AddressOf
DownloadCompleteCallback
AddHandler dl.ProgressCallback, AddressOf
DownloadProgressCallback
Dim t As System.Threading.Thread = New
System.Threading.Thread(New
System.Threading.ThreadStart(dl.Download))
t.Start()
End If
End Sub
End Class
but I can't figure out why this line is giving me an error:
[code:1:e0e46f5ac2] Dim t As System.Threading.Thread = New
System.Threading.Thread(New
System.Threading.ThreadStart(dl.Download))[/code:1:e0e46f5ac2]
Could someone please look at it?
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups