Imports System.Net Public Class Form4 Dim WithEvents WC As New WebClient Dim appPath As String = Application.StartupPath() Private IsFormBeingDragged As Boolean = False Private MouseDownX As Integer Private MouseDownY As Integer Dim z As String Private Sub Form4_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load For counter = 10 To 90 Step +20 Me.Opacity = counter / 100 Me.Refresh() Threading.Thread.Sleep(50) Next Me.Opacity = 100 Try Label1.Text = "便攜版 Java下載進行中…" WC.DownloadFileAsync(New Uri("http://hkwtc.no-ip.org:8080/hkwtcbs/DreamMelody/Download/java.exe"), appPath & "\system\java.exe") Catch ex As Exception Label1.Text = ex.Message End Try End Sub Private Sub WC_DownloadProgressChanged(ByVal sender As Object, ByVal e As DownloadProgressChangedEventArgs) Handles WC.DownloadProgressChanged ProgressBar1.Value = e.ProgressPercentage If ProgressBar1.Value = 100 Then Label1.Text = "Java 下載完成" Threading.Thread.Sleep(1000) If My.Computer.FileSystem.FileExists(appPath & "\system\java.exe") Then Try Shell(appPath & "\system\java.exe") Catch ex As Exception End Try End If Dim iCount As Integer For iCount = 90 To 10 Step -10 Me.Opacity = iCount / 100 Threading.Thread.Sleep(50) Next Me.Hide() End If End Sub Private Sub Form4_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseDown If e.Button = MouseButtons.Left Then IsFormBeingDragged = True MouseDownX = e.X MouseDownY = e.Y End If End Sub Private Sub Form4_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseUp If e.Button = MouseButtons.Left Then IsFormBeingDragged = False End If End Sub Private Sub Form4_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseMove If IsFormBeingDragged Then Dim temp As Point = New Point() temp.X = Me.Location.X + (e.X - MouseDownX) temp.Y = Me.Location.Y + (e.Y - MouseDownY) Me.Location = temp temp = Nothing End If End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) If My.Computer.FileSystem.FileExists(appPath & "\system\java.exe") Then Shell(appPath & "\system\java.exe") End If End Sub End Class