It is to make a random math problem but all that shows up is the tall1+tall2 when it should sho 2+4 or 5+6
When you surround text with the quote characters ("), you’re telling the code, “I want to use these exact letters and numbers and punctuation”. So by having “tall1” that is literally saying, make the text include the letters t, a, l, l, and the number 1.
When you have a variable with a value assigned to it, you use the variable name directly to get its value. No other code or symbols are needed to get it out. For the value of tall1, simply use tall1
.
txtOppgave.text = String(tall1) + "+" + String(tall2);
As a number, it will have a numeric value that the String()
conversion function can change to a string for you. But when used with a +
and another string, it will be converted automatically making the String()
calls redundant. So all you really need, since you have that “+” string in there (not to be confused with the +
operator), is:
txtOppgave.text = tall1 + "+" + tall2;
This will resolve when obtaining the variable values to something like:
txtOppgave.text = 2 + "+" + 4;
Which in turn will become:
txtOppgave.text = "2+4";
OK! seriously thanks so much for the help!! You may actually have saved my grade!! thanks