Public Function BytesToMegabytes(Bytes As Double) As Double Dim mathbtmb As Double math = (Bytes / 1024) / 1024 BytesToMegabytes = Format(mathbtmb, "###,###,##0.00") ' 0 for more decimal places. End Function
Function Numeric2Bytes(ByVal b As Double) As String
Dim byteSize(8) As String
Dim i As Integer
byteSize(0) = "Bytes"
byteSize(1) = "KB"
byteSize(2) = "MB"
b = CDbl(b)
For i = UBound(bytesize) To 0 Step -1
If b >= (1024 ^ i) Then
Numeric2Bytes = ThreeNonZeroDigits(byte / (1024 ^ _
i)) & " " & byteSize(i)
Exit For
End If
Next
End Function
Private Function ThreeNonZeroDigits(ByVal value As Double) _
As String
If value >= 100 Then
Return Format$(CInt(value))
ElseIf value >= 10 Then
Return Format$(value, "0.0")
Else
Return Format$(value, "0.00")
End If
End Function
If mathbytes >= 1.890 then label1.text = 2 'or whatever end if ' or else end if
