B4J Question Filesize with NumberFormat

ThRuST

Well-Known Member
Licensed User
Longtime User
I have this code. Can you help me implement NumberFormat to remove the decimals?

Play around with this
B4X:
Private FileSize As Int
    FileSize = File.Size ("c:\","Filename")
    fx.Msgbox(MainForm, FileSize / 1024, "")
 

ThRuST

Well-Known Member
Licensed User
Longtime User
This makes sense, but not correct. Was it close?

B4X:
Private FileSize As Int
    FileSize = File.Size ("c:\","test.exe")
    fx.Msgbox(MainForm, FileSize(NumberFormat(1,3,0) / 1024, ""))
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
You might win a box of twix if you provide a working solution to this, you never know haha
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
I also tried this

B4X:
fx.Msgbox(MainForm, FileSize / 1024 (NumberFormat(1,3,0)), "")
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
And this

B4X:
fx.Msgbox(MainForm, NumberFormat(FileSize,3,0) / 1024, "")
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
@DonManfred Great. This is the closest I got but it still returns 3 decimals because it uses Double. Even tried Ceil and Round but that's not the way to go

B4X:
Private FileSize As Double
    FileSize = File.Size ("c:\","test.exe")
    fx.Msgbox(MainForm, NumberFormat(FileSize,3,0 / 1024), "")
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Actually this question was a follow up to Resumable subs. So that the value of Sleep can be adjusted according to the size of a file.
Madness or Genious, the beauty is in the eyes of the beholder. Your solution was once again better than my own
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…