Converting bytes to kB, MB, etc. - InfoPath Dev
in

InfoPath Dev

Converting bytes to kB, MB, etc.

Last post 08-02-2010 02:39 AM by Michael089. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 07-30-2010 05:17 AM

    Converting bytes to kB, MB, etc.

    Hi, 

    I've a form with a field which shows the size of a file in bytes. This is a regular textbox with an integer value. Unfortunately, this can be quite confusing when file are large. Therefore I want to display (!) the corresponding kB, MB, GB value for the file in this textbox instead of the byte value, if the file is larger than 1024, (1024*1024), etc. bytes! If possible, I'd like to do this in the same textbox - if not an expression box would be ok as well! I've no idea how to do this - I tried it with conditional formatting, but I did not come to a good solution.

     Anyone any ideas? Thanks,

     

    Michael

     

     

  • 07-30-2010 08:46 AM In reply to

    Re: Converting bytes to kB, MB, etc.

    Where is the value coming from?  Is it manually entered by a user?  Copied from somewhere?  You should most likely be able to set up a rule with a set of conditions to overwrite the field's own value or (probably better) set an other field's value with the number of KiB, MiB, GiB, TiB, etc.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 08-02-2010 02:39 AM In reply to

    Re: Converting bytes to kB, MB, etc.

     Hi Jimmy,

     the values come from an XML file - some values (such as the file size) are already in the XML - other values should be edited by the user via InfoPath. I don't think I can do this with a rule, since as far as I understand, a rule is executed as soon as the users edits a field (I'm pretty new to InfoPath - so I don't know if that is really true). 

    I can also use a new field since the file size does not need to be updated or changed - but I still have the problem, that I need to do the following steps:

    • check the file size (= >1024 or >1024*1024 ...)
    • divide the file size by 1024 or 1024*1024 ...
    • show the nicely converted figure (kB, MB, GB ..) in the new field

    Previously, I used XSLT to display the XML data in a browser - there this was simple since a could use conditional statements and mathematical operations on the XML data! 

     Regards,

     Michael 

     

Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.