Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to write the code of VB.NET download program

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Today, I will talk to you about how to write the VB.NET download program implementation code, which may not be well understood by many people. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

For the application of VB.NET language, there are many tips for us to master to enrich our development experience and improve programming efficiency. For example, the implementation of the VB.NET download program is one of the useful programming skills, which can help us to solve the related problems encountered in the development.

Sample VB.NET downloader code:

Public Shared fpath As String

Dim fsize As Long

Private Sub Button1_Click (ByVal sender As System.Object

ByVal e As System.EventArgs) Handles Button1.Click

Try

If Me.TextBox1.Text = "http://" Then

MessageBox.Show ("Please enter the correct URL!")

Return

End If

Dim urld As String

Dim i As Integer

Dim dfile As New WebClient

Me.SaveFileDialog1.ShowDialog ()

Fpath = SaveFileDialog1.FileName

Label3.Text = "File saved in:" & fpath

Urld = Me.TextBox1.Text

Me.Timer1.Enabled = True

Dfile.DownloadFile (urld, fpath.Substring

(Me.TextBox1.Text.ToString.LastIndexOf ("."), 4)

Me.Timer1.Enabled = False

Catch ex As Exception

MessageBox.Show (ex.Message)

Return

Application.Exit ()

End Try

End Sub

Private Sub Timer1_Tick (ByVal sender As System.Object

ByVal e As System.EventArgs) Handles Timer1.Tick

Dim th3 As New th2

Dim tt As New System.Threading.Thread (AddressOf th3.timeth)

'Instantiate the thread class

Tt.Start () 'start thread

Label2.Text = th3.downk 'shows the size of the downloaded file

'calculate the download speed

Static k As Integer

Dim p, downspeed

P = k

K = p + 1

P = k

Dim form As New DownLoad

Dim fileinfo As New System.IO.FileInfo (form.fpath)

Downspeed = fileinfo.Length ()

Downspeeddownspeed = downspeed / p

Label4.Text = "current download speed is" & downspeed & "KANGA"

End Sub

End Class

Public Class th2

Public Shared downk As String

Dim form As New DownLoad

Dim fileinfo As New System.IO.FileInfo (form.fpath)

Dim fsize As Long

Public Sub timeth ()

If fileinfo.Exists = True Then

Fsize = fileinfo.Length ()

Downk = "to download files" & fsize & "k"

End If

End Sub

End Class

After reading the above, do you have any further understanding of how to write the implementation code of the VB.NET download program? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report