Hallo,
ich habe ein Problem und zwar:
wenn ich mein programm starte und der Download aktiv wird, dann ändert die form die text farbe wieder auf standart "schwarz".
Eingestellt ist Weiß.
kennt jemand den Fehler ?
Spoiler anzeigen
ich habe ein Problem und zwar:
wenn ich mein programm starte und der Download aktiv wird, dann ändert die form die text farbe wieder auf standart "schwarz".
Eingestellt ist Weiß.
kennt jemand den Fehler ?
VB.NET-Quellcode
- Option Strict On
- Imports System.Net
- Imports System.Text
- Public Class Form1
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- Using web = New WebClient() With {.Proxy = Nothing, .Encoding = Encoding.Default}
- Label4.Text = web.DownloadString("http://")
- End Using
- Timer1.Start()
- End Sub
- Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
- Dim client As WebClient = New WebClient
- AddHandler client.DownloadProgressChanged, AddressOf client_ProgressChanged
- AddHandler client.DownloadFileCompleted, AddressOf client_DownloadCompleted
- SW = Stopwatch.StartNew
- client.DownloadFileAsync(New Uri("http://download.thinkbroadband.com/200MB.zip"), Environment.CurrentDirectory & "\200MB.zip")
- Me.Text = "Download in Progress"
- Me.Enabled = False
- Timer1.Stop()
- End Sub
- Dim sw As New Stopwatch
- Private Sub client_ProgressChanged(ByVal sender As Object, ByVal e As DownloadProgressChangedEventArgs)
- Dim downloaded As String = CType(e.BytesReceived / 1024, String)
- Dim mussdownloaden As String = CType(e.TotalBytesToReceive / 1024, String)
- ProgressBar1.Value = e.ProgressPercentage
- Label1.Text = String.Format("{0:0.00} MB von {1:0.00} MB", e.BytesReceived / 1024 / 1024, e.TotalBytesToReceive / 1024 / 1024)
- Label2.Text = e.ProgressPercentage & "%"
- End Sub
- Private Sub client_DownloadCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs)
- MessageBox.Show("Download Complete")
- Me.Text = "Start Download"
- Me.Enabled = True
- Me.ProgressBar1.Value = 0
- Me.Label1.Text = "0 von 0 Bytes"
- Me.Label2.Text = "0%"
- End Sub
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- Me.Close()
- End Sub
- End Class