这应该是一个程序,它告诉您在用户输入下载速度后下载给定大小的文件需要多长时间。intOne 似乎完全不受我创建的用于确定 intOne 值的函数的影响。我有理由确定我使用的方程式是正确的。
Public Class Form1
Private tSize As System.Drawing.Size
Private checkUserSpeed As Long = 0
Private checkBitByte As Integer = 0
Private setSize As Integer = 0
Private checkUserSize As String = ""
Private Answer As Double = 0
Private ReadOnly Property checkDwnldSize() As String
Get
Return ComboBox1.Text
End Get
End Property
Function checkDownloadSize(ByVal checkUserSize As String)
Dim suffixes As New List(Of String)({"b", "k", "m", "g", "t", "p", "e", "z"})
Dim index As Long = suffixes.IndexOf(checkUserSize.Substring(0, 1).ToLower) > -1
If index > -1 Then
Return checkUserSpeed / 1024 ^ index
Else
Return False
End If
End Function
Function checkForByte(ByVal checkUserSize)
If Microsoft.VisualBasic.Right(checkUserSize.ToLower, 7) = "byte(s)" Then
checkBitByte = 1
checkDownloadSize(checkUserSize)
Return True
End
Else
Return False
End If
Return checkBitByte
Return checkUserSpeed
End Function
Function checkForBit(ByVal checkUserSize)
If Microsoft.VisualBasic.Right(checkUserSize.ToLower, 6) = "bit(s)" Then
checkBitByte = 8
checkDownloadSize(checkUserSize)
Return True
End
Else
checkForByte(checkUserSize)
Return False
End If
Return checkBitByte
Return checkUserSpeed
End Function
Function Calculate(ByVal checkUserSpeed, ByVal checkUserSize)
checkForBit(checkUserSize)
Return Answer
End Function
Private Sub FitContents()
tSize = TextRenderer.MeasureText(TextBox3.Text, TextBox3.Font)
TextBox3.Width = tSize.Width + 10
TextBox3.Height = tSize.Height
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Calculate(Convert.ToInt32(TextBox3.Text), ComboBox3.Text)
Answer = checkBitByte * ((1024 ^ setSize) / checkUserSpeed)
TextBox1.Text = Answer
End Sub
Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
Call FitContents()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Form2.Show()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Form3.Show()
End Sub
End Class
帮助将不胜感激。