Bytes -> Megabytes Converter Function

Posted On 2018-02-11 by IntellgentSolutions
Keywords:
Tags: VB6 Math/Dates VB6 Custom Functions 
Views: 80


Converts a figure represented in bytes to the corresponding figure in megabytes, formatted to two decimal places. With a little modification, this could also be converted into a multi-value converter for kilobytes, gigabytes, terabytes, petabytes, etc.

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


About the Author

has posted a total of 1 articles.


Comments On This Post

No comments on this post yet!


Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.

Or you can drop a note to the administrators if you're not sure where you should post.


Your IP address is:54.81.68.240

Before you can post, you need to prove you are human. If you log in, this test goes away.


Code Links