我的上一个问题让我想到了这个问题:
wxTextCtrl:setValue( TcGrossProfit, io_lib:format("~.2f",[NewGrossProfit])),
从wxTextCtrl生成一个错误的arg。
我知道这是罪魁祸首
NewGrossProfit = 5.45333,
io_lib:format("~.2f",[NewGrossProfit])
感谢最后一个,希望这个更容易
-B
修改
最后一个问题: Truncate a float in Erlang
答案 0 :(得分:5)
问题是io_lib:format("~.2f",[NewGrossProfit])
会返回一个iolist:["5.45"]
,但wxTextCtrl:setValue
似乎需要一个字符串("5.45"
)。所以
wxTextCtrl:setValue( TcGrossProfit, lists:flatten(io_lib:format("~.2f",[NewGrossProfit])))
应该有用。