Hi,
I would like to create a little game with randomized calculator operations (+ - * / ).
While I do not have any problem randomizing numbers, I'm confused about symbols.
Thanks in advance
Thanks, it works perfectly.? But I thought I could use this variable (operator) in the calculator operation instead of the operator such as:
resultField = num1 operator num2
but it doesn't work in this way. I mean, if I decide the operator in the code it works
resultFiled = num1 + num2 'where resultField is the sum of num1 + num2 and I declared Private resultField As EditText in Sub Globals
what's wrong here?
ERRATA CORRIGE
Thanks, it works perfectly.? But I thought I could use this variable (operator) in the calculator operation instead of the operator such as:
resultField = num1 operator num2
but it doesn't work in this way. I mean, if I decide the operator in the code it works
resultFiled = num1 + num2 'where resultField is the sum of num1 + num2 and I declared Private resultField As EditText in Sub Globals
what's wrong here?
I think I found a work around. I introduced a if test like:
If operator = "+" Then
resultInt = num1 + num2
Else If operator = "-" Then
resultInt = num1 - num2
.....
and so on for the other operators.
Thank you in advance for best suggestions.
Dim operators As List = Array("+", "-", "*", "/")
Dim operator As String = operators.Get(Rnd(0, operators.Size)) 'second Rnd parameter is exclusive
Select operator
Case "+"
YourCodeToAdd
Case "-"
YourCodeToSubtract
Case "*"
YourCodeToMultiply
Case "/"
YourCodeToDivide
End Select