![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Convert Bytes to Gigabytes Hi, I have a VBscript which I want to read data from an XML file produced by a backup application and post it into an excel spreedsheet for reference. At the moment we just write down the value and type it in, I want to automate this. I've got the script to pretty much work appart from the values it gets are in bytes and thus not really very meaninful. Then script reads the bytes from the XML file and then I tried to convert it to a double but it didn't like it because of the very large number. As such is there a way that I can convert the string to gigabytes before I made it into a double or int? This is driving me insane as I can't find anything useful anywhere online Any help/advice would be appreciated. All I need is a way to convert the bytes I have read to Gigabytes to be added to an excel spreedsheet. Thanks Steve |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Convert Bytes to Gigabytes On Jul 27, 6:55*am, SkySte <ste.is....@xxxxxx> wrote: Quote: > Hi, I have a VBscript which I want to read data from an XML file > produced by a backup application and post it into an excel spreedsheet > for reference. At the moment we just write down the value and type it > in, I want to automate this. I've got the script to pretty much work > appart from the values it gets are in bytes and thus not really very > meaninful. > > Then script reads the bytes from the XML file and then I tried to > convert it to a double but it didn't like it because of the very large > number. As such is there a way that I can convert the string to > gigabytes before I made it into a double or int? This is driving me > insane as I can't find anything useful anywhere online Any help/> advice would be appreciated. All I need is a way to convert the bytes > I have read to Gigabytes to be added to an excel spreedsheet. > > Thanks > Steve gbytes = Round(bytes / 1024^3, 3) Tom Lavedas *********** |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Convert Bytes to Gigabytes "SkySte" <ste.is.gr8@xxxxxx> wrote in message news:bed01341-9ff4-4a30-8101-ec1f7838ba55@xxxxxx Quote: > Hi, I have a VBscript which I want to read data from an XML file > produced by a backup application and post it into an excel spreedsheet > for reference. At the moment we just write down the value and type it > in, I want to automate this. I've got the script to pretty much work > appart from the values it gets are in bytes and thus not really very > meaninful. > > Then script reads the bytes from the XML file and then I tried to > convert it to a double but it didn't like it because of the very large > number. As such is there a way that I can convert the string to > gigabytes before I made it into a double or int? This is driving me > insane as I can't find anything useful anywhere online Any help/> advice would be appreciated. All I need is a way to convert the bytes > I have read to Gigabytes to be added to an excel spreedsheet. > > Thanks > Steve to kBytes: sCapacity = "1234567890" if len(sCapacity) > 3 then skBytes = Left(sCapacity, Len(sCapacity) - 3) if skBytes= "" then skBytes = 0 |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Convert Bytes to Gigabytes On Jul 27, 8:18*am, "Pegasus [MVP]" <n...@xxxxxx> wrote: Quote: > "SkySte" <ste.is....@xxxxxx> wrote in message > > news:bed01341-9ff4-4a30-8101-ec1f7838ba55@xxxxxx > > > Quote: > > Hi, I have a VBscript which I want to read data from an XML file > > produced by a backup application and post it into an excel spreedsheet > > for reference. At the moment we just write down the value and type it > > in, I want to automate this. I've got the script to pretty much work > > appart from the values it gets are in bytes and thus not really very > > meaninful. Quote: > > Then script reads the bytes from the XML file and then I tried to > > convert it to a double but it didn't like it because of the very large > > number. As such is there a way that I can convert the string to > > gigabytes before I made it into a double or int? This is driving me > > insane as I can't find anything useful anywhere online Any help/> > advice would be appreciated. All I need is a way to convert the bytes > > I have read to Gigabytes to be added to an excel spreedsheet. Quote: > > Thanks > > Steve > You could lop off the three right-most characters in order to convert Bytes > to kBytes: > sCapacity = "1234567890" > if len(sCapacity) > 3 then skBytes = Left(sCapacity, Len(sCapacity) - 3) > if skBytes= "" then skBytes = 0 GigaBytes are a count of 1024^3 byte blocks (2^30 bytes). You can see the effect of this distinction if you look at the Properties of a drive and note the difference between the bytes and GB properties for any of the capacity parameters listed in the dialog. Tom Lavedas *********** http://there.is.no.more/tglbatch/ |
My System Specs![]() |
| | #5 (permalink) |
| Vista home premium 32bit | Re: Convert Bytes to Gigabytes "SkySte" <ste.is.gr8@xxxxxx> wrote in message news:bed01341-9ff4-4a30-8101-ec1f7838ba55@xxxxxx Quote: > Hi, I have a VBscript which I want to read data from an XML file > produced by a backup application and post it into an excel spreedsheet > for reference. At the moment we just write down the value and type it > in, I want to automate this. I've got the script to pretty much work > appart from the values it gets are in bytes and thus not really very > meaninful. > > Then script reads the bytes from the XML file and then I tried to > convert it to a double but it didn't like it because of the very large > number. As such is there a way that I can convert the string to > gigabytes before I made it into a double or int? This is driving me > insane as I can't find anything useful anywhere online Any help/> advice would be appreciated. All I need is a way to convert the bytes > I have read to Gigabytes to be added to an excel spreedsheet. > > Thanks > Steve to kBytes: sCapacity = "1234567890" if len(sCapacity) > 3 then skBytes = Left(sCapacity, Len(sCapacity) - 3) if skBytes= "" then skBytes = 0 That would produce a 7% larger number. |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Convert Bytes to Gigabytes "Tom Lavedas" <tglbatch@xxxxxx> wrote in message news:1a5b9a4d-e27d-4ab8-8f17-1123e466bb10@xxxxxx On Jul 27, 8:18 am, "Pegasus [MVP]" <n...@xxxxxx> wrote: Quote: > "SkySte" <ste.is....@xxxxxx> wrote in message > > news:bed01341-9ff4-4a30-8101-ec1f7838ba55@xxxxxx > > > Quote: > > Hi, I have a VBscript which I want to read data from an XML file > > produced by a backup application and post it into an excel spreedsheet > > for reference. At the moment we just write down the value and type it > > in, I want to automate this. I've got the script to pretty much work > > appart from the values it gets are in bytes and thus not really very > > meaninful. Quote: > > Then script reads the bytes from the XML file and then I tried to > > convert it to a double but it didn't like it because of the very large > > number. As such is there a way that I can convert the string to > > gigabytes before I made it into a double or int? This is driving me > > insane as I can't find anything useful anywhere online Any help/> > advice would be appreciated. All I need is a way to convert the bytes > > I have read to Gigabytes to be added to an excel spreedsheet. Quote: > > Thanks > > Steve > You could lop off the three right-most characters in order to convert > Bytes > to kBytes: > sCapacity = "1234567890" > if len(sCapacity) > 3 then skBytes = Left(sCapacity, Len(sCapacity) - 3) > if skBytes= "" then skBytes = 0 GigaBytes are a count of 1024^3 byte blocks (2^30 bytes). You can see the effect of this distinction if you look at the Properties of a drive and note the difference between the bytes and GB properties for any of the capacity parameters listed in the dialog. Tom Lavedas *********** http://there.is.no.more/tglbatch/ ================ I'm quite aware of this difference. If it matters for the OP then it's a trivial thing to make the appropriate adjustment after lopping off the three trailing characters. With a little more effort he could even implement a rounding function. |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Convert Bytes to Gigabytes "whs" <guest@xxxxxx-email.com> wrote in message news:1eeec82dc44b27bcb8fcd8b8fda4fa70@xxxxxx-gateway.com... Quote: > > 'Pegasus [MVP Wrote: Quote: >> ;1099857']"SkySte" <ste.is.gr8@xxxxxx> wrote in message >> news:bed01341-9ff4-4a30-8101-ec1f7838ba55@xxxxxx> > > Quote: >> > > Hi, I have a VBscript which I want to read data from an XML file >> > > produced by a backup application and post it into an excel >> > spreedsheet >> > > for reference. At the moment we just write down the value and type it >> > > in, I want to automate this. I've got the script to pretty much work >> > > appart from the values it gets are in bytes and thus not really very >> > > meaninful. >> > > >> > > Then script reads the bytes from the XML file and then I tried to >> > > convert it to a double but it didn't like it because of the very >> > large >> > > number. As such is there a way that I can convert the string to >> > > gigabytes before I made it into a double or int? This is driving me >> > > insane as I can't find anything useful anywhere online Any help/>> > > advice would be appreciated. All I need is a way to convert the bytes >> > > I have read to Gigabytes to be added to an excel spreedsheet. >> > > >> > > Thanks >> > > Steve > > >> You could lop off the three right-most characters in order to convert >> Bytes >> to kBytes: >> sCapacity = "1234567890" >> if len(sCapacity) > 3 then skBytes = Left(sCapacity, Len(sCapacity) - >> 3) >> if skBytes= "" then skBytes = 0 > > That would produce a 7% larger number. > > > -- > whs of a beginner in VB Script programming. |
My System Specs![]() |
| | #8 (permalink) |
| Vista home premium 32bit | Re: Convert Bytes to Gigabytes "whs" <guest@xxxxxx-email.com> wrote in message news:1eeec82dc44b27bcb8fcd8b8fda4fa70@xxxxxx-gateway.com... Quote: > > 'Pegasus [MVP Wrote: Quote: >> ;1099857']"SkySte" <ste.is.gr8@xxxxxx> wrote in message >> news:bed01341-9ff4-4a30-8101-ec1f7838ba55@xxxxxx> > > >> >> You could lop off the three right-most characters in order to convert >> Bytes >> to kBytes: >> sCapacity = "1234567890" >> if len(sCapacity) > 3 then skBytes = Left(sCapacity, Len(sCapacity) - >> 3) >> if skBytes= "" then skBytes = 0 > > That would produce a 7% larger number. > > > -- > whs of a beginner in VB Script programming. 2.4% for Megabytes and 7% for Giga bytes. Multiply 1024x1024x1024 and see what the result is. |
My System Specs![]() |
| | #9 (permalink) |
| | Re: Convert Bytes to Gigabytes "whs" <guest@xxxxxx-email.com> wrote in message news:5a2bf51e64d770cb0c17cf0c81f26981@xxxxxx-gateway.com... Quote: > > 'Pegasus [MVP Wrote: Quote: >> ;1100000']"whs" <guest@xxxxxx-email.com> wrote in message >> news:1eeec82dc44b27bcb8fcd8b8fda4fa70@xxxxxx-gateway.com...> > > Quote: >> > > >> > > 'Pegasus [MVP Wrote:> > > > > >> > > >> ;1099857']"SkySte" <ste.is.gr8@xxxxxx> wrote in message >> > > >> news:bed01341-9ff4-4a30-8101-ec1f7838ba55@xxxxxx> > > >> > > >> >> > > >> You could lop off the three right-most characters in order to >> > > convert >> > > >> Bytes >> > > >> to kBytes: >> > > >> sCapacity = "1234567890" >> > > >> if len(sCapacity) > 3 then skBytes = Left(sCapacity, >> > > >> Len(sCapacity) >> > > - >> > > >> 3) >> > > >> if skBytes= "" then skBytes = 0> > > > >> > > >> > > >> > > That would produce a 7% larger number. >> > > >> > > >> > > -- >> > > whs > > >> 7%? More like 2.4%! And as I said - the cure is trivial, well within >> reach >> of a beginner in VB Script programming. > > 2.4% for Megabytes and 7% for Giga bytes. Multiply 1024x1024x1024 and > see what the result is. > > > -- > whs characters in order to convert Bytes to kBytes". Your figure of 7% (7.37%) applies to a triple conversion (Bytes to GBytes), which would be ridiculous because the OP would lose most of the information he is after. A conversion to kBytes is probably sufficient for his purpose, hence the uncompensated error is 2.4%. |
My System Specs![]() |
| | #10 (permalink) |
| | Re: Convert Bytes to Gigabytes Pegasus [MVP] wrote: Quote: > "Tom Lavedas" <tglbatch@xxxxxx> wrote in message > That's not the way it works, since bytes are the actual count and > GigaBytes are a count of 1024^3 byte blocks (2^30 bytes). You can see > the effect of this distinction if you look at the Properties of a > drive and note the difference between the bytes and GB properties for > any of the capacity parameters listed in the dialog. > > Tom Lavedas > *********** > http://there.is.no.more/tglbatch/ > > ================ > > I'm quite aware of this difference. If it matters for the OP then > it's a trivial thing to make the appropriate adjustment after lopping > off the three trailing characters. With a little more effort he could > even implement a rounding function. the correct way to count BYTEs and have been getting away with it for years. Perhaps they should be required to indicate their unit of measure is actually characters and not BYTEs. -- Todd Vargo (Post questions to group only. Remove "z" to email personal messages) |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| When using System.IO.FileStream, I write 8 bytes, then seek to the start of the file, does the 8 bytes get flushed on seek and the buffer become a readbuffer at that point instead of being a write buffer? | .NET General | |||
| Does Vista Actually Want 18 Gigabytes Of Disc Space? | Vista General | |||
| Re: Does Vista Actually Want 18 Gigabytes Of Disc Space? | Vista General | |||
| Re: Does Vista Actually Want 18 Gigabytes Of Disc Space? | Vista General | |||
| ISO only 712 bytes? | Vista General | |||