473,322 Members | 1,405 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

convert gb or mb to zeros or decimal places

I know it's possible, just don't know how to do it. I have a
spreadsheet that I imported into access. Two of the columns in the
table have Hard Drive space values listed for example 2.45 GB and 453
MB, you get the picture. Both the GB and MB assorted values exist in
both columns.

Is there anyway to convert the GB or MB to 0's, or even better yet
decimal places so I can look for values < or > to 6gb. I already tried
a query, but it seems that in it's current format, access can't
properly run the query, because it's only looking at the numeric value
and not the gb or mb attached to it.

Or is it simpler to do in Excel?

TIA,

Brian
Nov 12 '05 #1
2 15836
Strictly, 1KB is 1024 bytes.
1MB is 1024 squared.
1GB is 1024 cubed.

Open the Immediate Window (Ctrl+G), and enter:
? CLng(1024) * 1024
1 048 576

? CLng(1024) * 1024 * 1024
1 073 741 824

The conversion to Long is necessary because of the size of the numbers. To
go much larger, you may need to convert to Decimal, i.e. use CDec() instead
of CLng().

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Bubba" <n3***@hotmail.com> wrote in message
news:cc**************************@posting.google.c om...
I know it's possible, just don't know how to do it. I have a
spreadsheet that I imported into access. Two of the columns in the
table have Hard Drive space values listed for example 2.45 GB and 453
MB, you get the picture. Both the GB and MB assorted values exist in
both columns.

Is there anyway to convert the GB or MB to 0's, or even better yet
decimal places so I can look for values < or > to 6gb. I already tried
a query, but it seems that in it's current format, access can't
properly run the query, because it's only looking at the numeric value
and not the gb or mb attached to it.

Or is it simpler to do in Excel?

TIA,

Brian

Nov 12 '05 #2
Probably need a column in your query calling the following function where
InputStr is defined as text in your table

Function Convert(InputStr As String) As String

If IsNumeric(InputStr) Then
Convert = CDec(InputStr)
Exit Function
End If

If Right(InputStr, 2) = "mb" Then
Convert = CDec(Left(InputStr, Len(InputStr) - 2) * 1000000)
Exit Function
End If
If Right(InputStr, 2) = "gb" Then
Convert = CDec(Left(InputStr, Len(InputStr) - 2) * 1000000000)
Exit Function
End If

End Function

Phil
"Bubba" <n3***@hotmail.com> wrote in message
news:cc**************************@posting.google.c om...
I know it's possible, just don't know how to do it. I have a
spreadsheet that I imported into access. Two of the columns in the
table have Hard Drive space values listed for example 2.45 GB and 453
MB, you get the picture. Both the GB and MB assorted values exist in
both columns.

Is there anyway to convert the GB or MB to 0's, or even better yet
decimal places so I can look for values < or > to 6gb. I already tried
a query, but it seems that in it's current format, access can't
properly run the query, because it's only looking at the numeric value
and not the gb or mb attached to it.

Or is it simpler to do in Excel?

TIA,

Brian

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Gizmo | last post by:
Hi there i was wondering if any one new to a function that rounds up a float to so many decimal places. I have a number in bytes and converting it to mb's and gb's but once its converted i need to...
2
by: Scott | last post by:
I want to display a decimal as a currency value for instance £65.00 or £58.47, but at the moment the code doesn't seem to work correctly. Can I declare this variable to be shown with 2 decimal...
2
by: Andy | last post by:
Hi I'm really stuck outputting a double number to the console with three decimal places if the furthest right value is a zero. I can coutput the number 4.546 as 4.546 but then if I output...
52
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I convert a Number into a String with exactly 2 decimal places?...
19
by: VK | last post by:
http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/ b495b4898808fde0> is more than one month old - this may pose problem for posting over some news servers. This is why I'm...
3
by: =?Utf-8?B?U2NvdHQ=?= | last post by:
Hello, I would like to convert a double to a string and have the resulting string contain all of the original values after the decimal place. Currently, the problem that I am having is that the...
10
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I convert a Number into a String with exactly 2 decimal places?...
4
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I format a Number as a String with exactly 2 decimal places?...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.