bytes to whatever

March 23, 2009 by admin  
Filed under Visual Basic

Function SetBytes(Bytes) As String

On Error GoTo errorhandler

If Bytes >= 1073741824 Then
SetBytes = Format(Bytes / 1024 / 1024 / 1024, “#0.00″) _
& ” GB”
ElseIf Bytes >= 1048576 Then
SetBytes = Format(Bytes / 1024 / 1024, “#0.00″) & ” MB”
ElseIf Bytes >= 1024 Then
SetBytes = Format(Bytes / 1024, “#0.00″) & ” KB”
ElseIf Bytes < 1024 Then
SetBytes = Fix(Bytes) & ” Bytes”
End If

Exit Function
errorhandler:
SetBytes = “cannot compute”
End Function

Private Sub Form_Load()
MsgBox SetBytes(1100)
End Sub

Related posts:

  1. convert to binary Public Function CBin(ByVal Nr As Long, Optional Precision As Integer...
  2. Screen capture Screen capture using Visual Basic Private Declare Sub keybd_event Lib...
  3. Retrieves the path your application is running from. Private Sub Form_Load() MsgBox App.Path End Sub Bookmark It Hide...
  4. Get screen resolution with Visual Basic This Visual Basic example will find out your current screen...

Related posts brought to you by Yet Another Related Posts Plugin.

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!