help with a problem with a code

Piero753

Member
Hi all well, I'm new to this and I'm doing a basic program, when I press negative subtract -1 and when i press positive adds +1 just want to know how I can put a notice te when the result is 4 saying "lost" in the label 2 I try to add a timer but nothing does not work, I show a photo

sinttulofbr.jpg



I hope your help thanks :)
 

Piero753

Member
I tried this but the result does not come as a decimal

B4X:
Sub CheckScore
     If Label2.Text = 312 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 311 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 310 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0) 
    If Label2.Text = 309 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 308 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 307 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
    If Label2.Text = 306 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 304 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 303 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
    If Label2.Text = 302 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 301 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 300 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 299 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 298 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0) 
    If Label2.Text = 297 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 296 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 295 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
    If Label2.Text = 294 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 293 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 292 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
    If Label2.Text = 291 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 290 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
    If Label2.Text = 289 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 288 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 287 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0) 
    If Label2.Text = 286 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 285 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 284 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
    If Label2.Text = 283 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 282 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 281 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
    If Label2.Text = 280 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 279 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
    If Label2.Text = 278 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 277 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 276 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0) 
    If Label2.Text = 275 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 274 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 273 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
    If Label2.Text = 272 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 271 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 270 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
    If Label2.Text = 269 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 268 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 267 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 266 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 265 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
    If Label2.Text = 264 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 263 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
    If Label2.Text = 262 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 261 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)
     If Label2.Text = 260 Then Label1.Text = NumberFormat(Label1.Text / 5 ,1,0)
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
You can use

B4X:
If Label2.Text < 307 And Label2.Text > 260 Then Label1.Text = NumberFormat(Label1.Text / 6 ,1,0)

NumberFormat options can be found here
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
you can change the NumberFormat options to do that which are documented here here

You can choose how many decimals you want to display
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
in your code you have excluded the range 2-6 (< 2 less than 2 ,and , > 6 greater than 6)

try this .. Label 3 is greater than 1 AND less than 7.
B4X:
If Label3.text > 1 AND Label3.Text < 7 Then

Cheers mj
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
to do what ? .. need more information

Cheers mj
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
from what I know of your project , create a reset button and in the Click_Event empty the labels,

B4X:
Sub btnReset_Click
    Label1.Text = ""
    Label2.Text = ""
    Label3.Text = ""
    ToastMessageShow ("Resetting now ... ," False)
End Sub

Cheers mj
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Set the debug mode to 'Release' (see image) and run debug.
If your device is connected it will install directly to device.
An .apk file will be created in the Objects folder of your project. Transfer this to your device to Manually install. (have you set a project icon ? .. Menu > Project > Choose Icon.)

note: if your project filename contains spaces the apk file will be called "Result.apk"



Edit .. I reread your post .. If you only want to test your app then just connect your device an run debug . No need to set to Release.

You might want to read here Chapter 7 - Connecting your device

Beginners Guide

Cheers mj
 

Attachments

  • Capture.PNG
    Capture.PNG
    6.5 KB · Views: 263
Last edited:
Upvote 0
Top