The legal tricks-Learn Your Self

Latest gadgets,softwares,hardware,reviews,programming and campuses, game cheats ext......

Convert Bytes to Megabytes

Version Compatibility: Visual Basic 5, Visual Basic 6, Visual Basic.NET, ASP.NET

More information: Converts a figure represented in bytes to the corresponding figure in megabytes, formatted to two decimal places.

Instructions: Copy the declarations and code below and paste directly into your VB project.

Public Function BytesToMegabytes(Bytes As Double) As Double
'This function gives an estimate to two decimal
'places. For a more precise answer, format to
'more decimal places or just return dblAns

Dim dblAns As Double
dblAns = (Bytes / 1024) / 1024
BytesToMegabytes = Format(dblAns, "###,###,##0.00")

End Function

0 comments: