Also make sure that you do the calculation as REAL ARITHMETHIC and not as INTEGER ARITHMETIC.
There might also be a problem once the formula returns 0 (this is when currentshields + currentlife = 0), since dialog items get infinitely wide when setting their width to 0. So you might need to check if the formula returns 0 and if yes set the dialog item width to 1 to avoid this problem. (Or just plainly add a +1 at the end of the formula, which would result in a slight loss in accuracy).
Try this formula:
maxbarwidth / (maxshields + maxlife) * (currentshields + currentlife)
Also make sure that you do the calculation as REAL ARITHMETHIC and not as INTEGER ARITHMETIC.
There might also be a problem once the formula returns 0 (this is when currentshields + currentlife = 0), since dialog items get infinitely wide when setting their width to 0. So you might need to check if the formula returns 0 and if yes set the dialog item width to 1 to avoid this problem. (Or just plainly add a +1 at the end of the formula, which would result in a slight loss in accuracy).