solfinker Member Licensed User Longtime User Aug 19, 2015 #1 Hello! Every time the EditText field (Decimal_numbers) is modified, the corresponding Sub is executed. So far so god. But since I am using it to execute some calculations, I get en error whenever the field is empty. So I would need to perform the calculations only when the field is finally edited - when pressing the "return" key on the numeric keyboard, or I suppose I'd need it make no calculations at all when the field is blank. Thank you for your hints. I have used the following code: Code: Copy If txtVolume.text = "" Then txtVolume.text = "0" End If volume = txtVolume.text but I suppose there will be sth more elegant Last edited: Aug 19, 2015
Hello! Every time the EditText field (Decimal_numbers) is modified, the corresponding Sub is executed. So far so god. But since I am using it to execute some calculations, I get en error whenever the field is empty. So I would need to perform the calculations only when the field is finally edited - when pressing the "return" key on the numeric keyboard, or I suppose I'd need it make no calculations at all when the field is blank. Thank you for your hints. I have used the following code: Code: Copy If txtVolume.text = "" Then txtVolume.text = "0" End If volume = txtVolume.text but I suppose there will be sth more elegant
Erel B4X founder Staff member Licensed User Longtime User Aug 20, 2015 #2 Both options are possible. If you like to make the calculation after the user filled the field then you can add a "calc" button or handle the EnterPressed event (make sure that ForceDone is set to true). You can use IsNumber(txtVolume.Text) to check whether there is a valid number. Upvote 0
Both options are possible. If you like to make the calculation after the user filled the field then you can add a "calc" button or handle the EnterPressed event (make sure that ForceDone is set to true). You can use IsNumber(txtVolume.Text) to check whether there is a valid number.