string convert to operator
-
Dear All, I have a problem If I insert values from text boxes as 3, +, 2 and I catch it for string variables. a = textbox1.text b = textboxt2.text c = textbox3.text Then I want to calculate those values ex: total = 3+2 virtually, total = a b c (because b="+") How can I do this, please help Thanks
-
Dear All, I have a problem If I insert values from text boxes as 3, +, 2 and I catch it for string variables. a = textbox1.text b = textboxt2.text c = textbox3.text Then I want to calculate those values ex: total = 3+2 virtually, total = a b c (because b="+") How can I do this, please help Thanks
want you have here is a casting problem. i guess that you want have the option to have different operators in the in 'b' so you could do basic maths operation....+ \ - * if this is so...what i would so is have b a dropdownlist or combobox with the selection fixed and maybe have it defaulted to '+' the next thing to do if make textbox 'a' and 'c' only except numbers, you can find many example of this on the web and once you have done this because you know that only number are going be entered you can cast the strings to ints i.e. Dim int1 As Integer = CType(textbox1, Integer) Dim int2 As Integer = CType(textbox3, Integer) then based on the selection do a case select to do the calculation hope this is what you wanted....
-
want you have here is a casting problem. i guess that you want have the option to have different operators in the in 'b' so you could do basic maths operation....+ \ - * if this is so...what i would so is have b a dropdownlist or combobox with the selection fixed and maybe have it defaulted to '+' the next thing to do if make textbox 'a' and 'c' only except numbers, you can find many example of this on the web and once you have done this because you know that only number are going be entered you can cast the strings to ints i.e. Dim int1 As Integer = CType(textbox1, Integer) Dim int2 As Integer = CType(textbox3, Integer) then based on the selection do a case select to do the calculation hope this is what you wanted....
Thank you very much Fu Manchu, Yes, it is ok for a and c. But how can I include b ("+" or may be "-", "*", "/" something like that). Becuase the operator is as in the textbox text, therefore I want to it convert to operator and also, include into equation. Is it possible?? If I describe further, there are three texboxes in the application. So user can type values in 1st and 3rd textboxes and operator (may be one of these +, -, *, /) in 2nd text box. Then application should give the results. help me, Thanks