UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Converting Mb To Gb Files.., Any Version    
 
   
Larry Larsen
post Feb 20 2020, 07:50 AM
Post#1


UA Editor + Utterly Certified
Posts: 24,527
Joined: 26-August 02
From: Melton Mowbray,Leicestershire (U.K)


Hi

I seem to have stumbled across a limit whilst try to convert MB to GB..

In the image I get an "Over Flow" error message..??

The actual file size is: 2.72 GB (2,929,270,784 bytes)

It would seem any thing under 2GB is converting ok...

Does or is my [.Size] limited..??
iconfused.gif
Attached File(s)
Attached File  2020_02_20_12_44_46.jpg ( 26.72K )Number of downloads: 0
 

--------------------
"Time...We have exactly the same number of hours per day that were given to Helen Keller, Pasteur, Michaelangelo, Mother Teresa, Leonardo da Vinci, Thomas Jefferson, and Albert Einstein"
H. Jackson Brown
Go to the top of the page
 
cheekybuddha
post Feb 20 2020, 08:00 AM
Post#2


UtterAccess Moderator
Posts: 12,621
Joined: 6-December 03
From: Telegraph Hill


Hi Larry,
Can you post the function FormatFileSize() ?

--------------------


Regards,

David Marten
Go to the top of the page
 
Doug Steele
post Feb 20 2020, 08:02 AM
Post#3


UtterAccess VIP
Posts: 22,263
Joined: 8-January 07
From: St. Catharines, ON (Canada)


What's the definition of FormatFileSize, Larry?

If it's looking for a Long passed to it, remember that the largest value you can pass is 2,147,483,647.

--------------------
Doug Steele, Microsoft Access MVP (2000-2018)
Personal webpage
Microsoft profile
Co-author: Access Solutions: Tips, Tricks, and Secrets from Microsoft Access MVPs, published by Wiley
Co-author: Effective SQL: 61 Specific Ways to Write Better SQL, published by Addison-Wesley Professional
Technical Editor: Access 2010 Bible, Access 2013 Bible, Access 2016 Bible, all published by Wiley
Technical Editor: SQL Queries for Mere Mortals: A Hands-On Guide to Data Manipulation in SQL, 4th Edition, published by Addison-Wesley Professional
Go to the top of the page
 
Larry Larsen
post Feb 20 2020, 08:09 AM
Post#4


UA Editor + Utterly Certified
Posts: 24,527
Joined: 26-August 02
From: Melton Mowbray,Leicestershire (U.K)


Here you go:
CODE
Public Function FormatFileSize(ByVal lngFileSize As Long) As String

  Dim x      As Integer:      x = 0
  Dim Suffix As String:  Suffix = ""
  Dim Result As Single:  Result = lngFileSize

  Do Until Int(Result) < 1000
     x = x + 1
     Result = Result / 1024
  Loop

  Result = Round(Result, 2)

  Select Case x
         Case 0
              Suffix = "Bytes"
         Case 1 'KiloBytes
              Suffix = "KB"
         Case 2 'MegaBytes
              Suffix = "MB"
         Case 3 'GigaBytes
              Suffix = "GB"
         Case 4 'TeraBytes
              Suffix = "TB"
         Case 5 'PetaBytes
              Suffix = "PB"
         Case 6 'ExaBytes
              Suffix = "EB"
         Case 7 'ZettaBytes
              Suffix = "ZB"
         Case 8 'YottaBytes
              Suffix = "YB"
         Case Else
              Suffix = "Too big to compute :)"
  End Select

  FormatFileSize = Format(Result, "#,##0.00") & " " & Suffix

End Function 'FormatFileSize

Note: Of Internet..
thumbup.gif

--------------------
"Time...We have exactly the same number of hours per day that were given to Helen Keller, Pasteur, Michaelangelo, Mother Teresa, Leonardo da Vinci, Thomas Jefferson, and Albert Einstein"
H. Jackson Brown
Go to the top of the page
 
cheekybuddha
post Feb 20 2020, 08:16 AM
Post#5


UtterAccess Moderator
Posts: 12,621
Joined: 6-December 03
From: Telegraph Hill


Hi Larry,

The MAXIMUM Value for a LONG INTEGER Field is 2,147,483,647.

Untested, but try adjusting the function to:
CODE
Public Function FormatFileSize(ByVal lngFileSize As Variant) As String

  Dim x      As Integer:      x = 0
  Dim Suffix As String:  Suffix = ""
  Dim Result As Single:  Result = lngFileSize

  Do Until Int(Result) < 1000
     x = x + 1
     Result = Result / 1024
  Loop

  Result = Round(Result, 2)

  Select Case x
         Case 0
              Suffix = "Bytes"
         Case 1 'KiloBytes
              Suffix = "KB"
         Case 2 'MegaBytes
              Suffix = "MB"
         Case 3 'GigaBytes
              Suffix = "GB"
         Case 4 'TeraBytes
              Suffix = "TB"
         Case 5 'PetaBytes
              Suffix = "PB"
         Case 6 'ExaBytes
              Suffix = "EB"
         Case 7 'ZettaBytes
              Suffix = "ZB"
         Case 8 'YottaBytes
              Suffix = "YB"
         Case Else
              Suffix = "Too big to compute :)"
  End Select

  FormatFileSize = Format(Result, "#,##0.00") & " " & Suffix

End Function 'FormatFileSize


hth,

d

--------------------


Regards,

David Marten
Go to the top of the page
 
Larry Larsen
post Feb 20 2020, 08:25 AM
Post#6


UA Editor + Utterly Certified
Posts: 24,527
Joined: 26-August 02
From: Melton Mowbray,Leicestershire (U.K)


Hi David..

That's better, it wasn't till I counted the number of 2GB files that I posted up the question..

QUOTE
They said never bigger than 1GB.... confused.gif


Many thanks..
thumbup.gif

--------------------
"Time...We have exactly the same number of hours per day that were given to Helen Keller, Pasteur, Michaelangelo, Mother Teresa, Leonardo da Vinci, Thomas Jefferson, and Albert Einstein"
H. Jackson Brown
Go to the top of the page
 
cheekybuddha
post Feb 20 2020, 08:30 AM
Post#7


UtterAccess Moderator
Posts: 12,621
Joined: 6-December 03
From: Telegraph Hill


Since Access gained the ability to deal with BigInt's, was there ever an equivalent upgrade of VBA?

--------------------


Regards,

David Marten
Go to the top of the page
 
ADezii
post Feb 20 2020, 09:54 AM
Post#8



Posts: 2,835
Joined: 4-February 07
From: USA, Florida, Delray Beach


I do believe that you can eliminate the entire SELECT CASE...CASE...CASE ELSE...END SELECT Construct in determining the proper Suffix:
CODE
'**************************** CODE INTENTIONALLY OMITTED *****************************
intIndex = x + 1

varSuffix = Choose(intIndex, "Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")

MsgBox IIf(IsNull(varSuffix), "Way TOO Big!", varSuffix)

NOTE: varSuffix must be Declared as Variant in order to Trap the potential NULL Value.
This post has been edited by ADezii: Feb 20 2020, 10:04 AM
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    6th April 2020 - 07:18 AM