1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
Private Function BytestoString(ByVal Size As Long) As String
Dim txt As String = Nothing
Try
Dim i As Integer = 1024
Dim i1 As Integer = i * i
Dim bl As Boolean = Size < CType(i, Long)
If bl Then
If Size <= 1 Then
Return String.Concat(Size.ToString("D"), " octet")
Else
Return String.Concat(Size.ToString("D"), " octets")
End If
Else
Dim dbl As Double = CType(Size, Double) / CType(i, Double)
bl = dbl < 1000
If bl Then
Dim dbl1 As Double = CType(Size, Double) / CType(i, Double)
Return String.Concat(dbl1.ToString("N"), "Ko")
Else
bl = dbl < 1000000
If bl Then
Dim dbl1 = CType(Size, Double) / CType(i1, Double)
Return String.Concat(dbl1.ToString("N"), "Mo")
Else
bl = dbl < 30000000
If bl Then
Dim dbl1 = (CType(Size, Double) / CType(i1, Double)) / CType(i, Double)
Return String.Concat(dbl1.ToString("N"), "Go")
End If
End If
End If
End If
Catch exception1 As Exception
txt = Size.ToString
Interaction.MsgBox(exception1.Message, MsgBoxStyle.Information)
Return txt
End Try
Return txt
End Function |
Partager