F Fabvitor New Member Sep 2, 2017 #1 Doubt I want to get numeric values, convert to double, perform operations and return to the textbox as string How do I do? Code: Sub Button3_Click Dim pa As Double, pb As Double, pc As Double, pda As Double, pdb As Double, pdc As Double, pd As Double, pcd As Double, pcc As Double Try pa = EditText1.Text pb = EditText2.Text pc = EditText3.Text pda = EditText4.Text pdb = EditText5.Text pdc = EditText6.Text pd = (pda * pa) + (pdb * pb) + (pdc * pc) pcc = (pdc * pc) pcd = (pdc * pc) / pd pcc = EditText7.Text pd = EditText8.Text pcd = EditText9.Text Catch Log(LastException) End Try End Sub
Doubt I want to get numeric values, convert to double, perform operations and return to the textbox as string How do I do? Code: Sub Button3_Click Dim pa As Double, pb As Double, pc As Double, pda As Double, pdb As Double, pdc As Double, pd As Double, pcd As Double, pcc As Double Try pa = EditText1.Text pb = EditText2.Text pc = EditText3.Text pda = EditText4.Text pdb = EditText5.Text pdc = EditText6.Text pd = (pda * pa) + (pdb * pb) + (pdc * pc) pcc = (pdc * pc) pcd = (pdc * pc) / pd pcc = EditText7.Text pd = EditText8.Text pcd = EditText9.Text Catch Log(LastException) End Try End Sub
Erel B4X founder Staff member Licensed User Longtime User Sep 2, 2017 #2 Please use [code]code here...[/code] tags when posting code. 1. Strings are converted to numbers automatically. 2. Use NumberFormat to convert a number to string. 3. Use IsNumber to test whether a string can be parsed to a number. Upvote 0
Please use [code]code here...[/code] tags when posting code. 1. Strings are converted to numbers automatically. 2. Use NumberFormat to convert a number to string. 3. Use IsNumber to test whether a string can be parsed to a number.
klaus Expert Licensed User Longtime User Sep 3, 2017 #3 Code: Copy pd = (pda * pa) + (pdb * pb) + (pdc * pc) pcc = (pdc * pc) pcd = (pdc * pc) / pd pcc = EditText7.Text pd = EditText8.Text pcd = EditText9.Text The last three lines look strange to me. You are calculating pd, pcc and pcd. I thinl that you want to show the results in the EditText views. If yes the code must be: Code: Copy EditText7.Text = NumberFormat(pcc, 1, 2) EditText8.Text = NumberFormat(pd, 1, 2) EditText9.Text = NumberFormat(pcd, 1, 2) You can change the two values in NumberFormat to your needs. Upvote 0
Code: Copy pd = (pda * pa) + (pdb * pb) + (pdc * pc) pcc = (pdc * pc) pcd = (pdc * pc) / pd pcc = EditText7.Text pd = EditText8.Text pcd = EditText9.Text The last three lines look strange to me. You are calculating pd, pcc and pcd. I thinl that you want to show the results in the EditText views. If yes the code must be: Code: Copy EditText7.Text = NumberFormat(pcc, 1, 2) EditText8.Text = NumberFormat(pd, 1, 2) EditText9.Text = NumberFormat(pcd, 1, 2) You can change the two values in NumberFormat to your needs.