Button not initialized.

Gavin

Member
Licensed User
Longtime User
Hi everybody.
Firstly, I am new to Basic4Android but have some experience with Power Basic for Windows. I have followed the first two examples in the tutorial and every thing seems fine. However, I notice when running the code as listed that the colour of the "Comments" label changes only from the second and subsequent passes. I tried stepping through the code using the "F8" key and all was fine until the sub "btnAction_Click". When the cursor reached Dim btnSender As Button, the Local variables list showed that btnSender (Button ) was not initialized.
How and where should this button be initialized? I appears that this routine is similar to catching the Click event in Power Basic.
Thank You.
 

Theera

Expert
Licensed User
Longtime User
Hi Gavin,
In B4A ,you could create the views 2 strategies. The first using coding,you must always initailize them,and the second using designer,you don't initailize them. Please to download Klaus's manual in Documentation Tab
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
However, I notice when running the code as listed that the colour of the "Comments" label changes only from the second and subsequent passes.
This is a bug in the program, I introduced this when I had rewritten the chapter in the Beginner's Guide.
Go to the Designer, select btnAction and in the Text field replace OK by O K (a space between O and K) this will solve the problem.
Thank you for reporting this bug.

When the cursor reached Dim btnSender As Button, the Local variables list showed that btnSender (Button ) was not initialized.
How and where should this button be initialized?
To me this looks like a bug in the error checking since B4A 2.70.
I sent a bug report in the forum.

Best regards.
 
Upvote 0

Gavin

Member
Licensed User
Longtime User
Button not initialized, almost solved.

Thank you Klaus and Theera for your replies.
Learning to create buttons in code, not the designer, is a little in the future for me yet. As for Button not initialized, the error only appears when Stepping (F8).
I tried placing a break point in btnEvent_Click at "If lblResult.Text.Length > 0 Then". Press F5, run the program on the smart phone, make a mistake, press the "BS" key, the debugger stops at the break point, press F8 to step, all OK, press F5 to run, again all OK.
The problem of the colour change, yes, the test string in the source code is "O K" (Capital O, space, Capital K). The program was only looking for what it was told to look for. My mistake!
 
Upvote 0
Top