I did the first calculator tutorial with no problems. On the second one, it's throwing a java runtime error on this section of code:
B4X:
Sub New
Number1 = Rnd(1, 10)
Number2 = Rnd(1, 10)
lblNumber1.Text = Number1
lblNumber2.Text = Number2
lblComments.Text = "Enter the result" & CRLF & "and click on OK"
lblComments.Color = Colors.RGB(128,128,255)
lblResult.Text = ""
btn0.Visible = False
End Sub
The line lblNumber1.Text = Number1 gives the error "Object should first be initialized (Label). My code matches that in the tutorial exactly. Any ideas what could be causing this error?
UPDATE: I matched my code against the code in the source files and they're exactly the same except for two lines that are not included in the tutorial but wouldn't be the cause of this error message. Anyway, after adding the two lines, the code matches exactly, yet the source code version runs smoothly and my version throws the error message I mentioned above. How can this be?
Are you sure that the Label is spelled correctly in the Designer and in the Globals subroutine?
If you have B4A version 1.8 lblNumber1 should be displayed in red showing that the Label variable has not been declared.
I just tested the source code from version 1.6 of the Beginner's Guide and it works without any error.
:sign0013: My problem with Globals was due to typing all the code and not using the As pop-up list to select required int. The program now works OK.
Thank You for an excellent IDE. Regards pbmjoe