Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

Bytes To MegaBytes

Posted on December 14, 2013October 26, 2015 By David Kittell
    Function BytesToMegabytes(ByVal Bytes As String) As String
        Dim SetBytes As String
        SetBytes = ""
        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
        Return SetBytes
    End Function
Private Function BytesToMegabytes(ByVal Bytes As Long) As Long
        Dim dblAns As Double
        dblAns = (Bytes / 1024) / 1024
        BytesToMegabytes = Format(dblAns, "###,###,##0.00")

    End Function
Originally Posted on December 14, 2013
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code VB.NET

Post navigation

Previous post
Next post

Related Posts

New Line

Posted on March 4, 2013March 10, 2016

Often we forget what code we need to use to create a new line (line break), hopefully this will help. n = CR (Carriage Return) Used as a new line character in Unix r = LF (Line Feed) Used as a new line character in Mac OS nr = CR…

Read More

Ektron Find Replace Library Folder Names

Posted on October 23, 2013October 26, 2015

This script will rename folder paths of renamed CMS folders. SET XACT_ABORT ON BEGIN TRAN DECLARE @currtext NVARCHAR(255) DECLARE @newtext NVARCHAR(255) DECLARE @search NVARCHAR(500) DECLARE @replace VARCHAR(500) DECLARE @pos INT DECLARE @id BIGINT DECLARE @libtype_id INT — folder names SET @search = ” –string to find SET @replace = ”…

Read More

Bash – Get ARIN IP Information

Posted on July 16, 2021August 17, 2024

A bit crude but works # Prerequisite: brew install ipcalc # Place all the IP Addresses in a text file IPList.txt echo "IP Address|Root Owner|Owner|IP CIDR|IP RDNS" | tee ARIN.txt for ip in $(cat IPList.txt | sort); do arin=$(whois -h whois.arin.net "$ip") rootOwner=$(echo "$arin" | grep ‘Organization’ | cut -d…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes