W WDK Member Licensed User Nov 10, 2017 #1 I am using SetScale2 for my rounding. It is working great, except want to strip decimal places if they are zero. I am allowing for up to 10 decimal places. BG_CalculateFormula.SetScale2(10, BG_CalculateFormula.ROUND_HALF_UP) Example: Currently: 40468564.2240000000 Would like: 40468564.224 (stripping off 0s) If I have: 40468564.2240000001 I would still like to have: 40468564.2240000001 (this is working as expected) Thanks for any help! WDK
I am using SetScale2 for my rounding. It is working great, except want to strip decimal places if they are zero. I am allowing for up to 10 decimal places. BG_CalculateFormula.SetScale2(10, BG_CalculateFormula.ROUND_HALF_UP) Example: Currently: 40468564.2240000000 Would like: 40468564.224 (stripping off 0s) If I have: 40468564.2240000001 I would still like to have: 40468564.2240000001 (this is working as expected) Thanks for any help! WDK
OliverA Expert Licensed User Longtime User Nov 10, 2017 #2 Maybe: Code: Copy Dim stripped As String stripped = BG_CalculateFormula.ToString Dim m As Matcher m = Regex.Matcher("(.+?)(0+)$",stripped) If m.Find Then stripped = m.Group(1) End If Log(stripped) Upvote 0
Maybe: Code: Copy Dim stripped As String stripped = BG_CalculateFormula.ToString Dim m As Matcher m = Regex.Matcher("(.+?)(0+)$",stripped) If m.Find Then stripped = m.Group(1) End If Log(stripped)
Ed Brown Active Member Licensed User Longtime User Nov 11, 2017 #3 Can you simply add zero? Something like Code: Copy yourvar = yourvar + 0 That should recalc and drop off the trailing zeroes. Upvote 0
Can you simply add zero? Something like Code: Copy yourvar = yourvar + 0 That should recalc and drop off the trailing zeroes.
W WDK Member Licensed User Nov 11, 2017 #4 Thanks for taking the time to reply. I will test out the solutions today. WDK Upvote 0