Help with Calculations, and coding

tsund

Member
Licensed User
Longtime User
Hi Everyone I am new to B4A and am new to this coding language. I need some help with an app I am making which sets four peoples scores, and then you can deduct points from their scores individually. I would also like to have a button which sets the initial score, and one to reset activity to zero. This is a complicated first project and would appreciate some help. I know there are many errors in this, I am looking for some constructive feed back to tell me what im doing wrong and where to go next. Please Have a look at my coding and feel free to change what you want to get it to work. I hope the community is as helpful as it seems!
Thanks for your time.:sign0188:

:sign0013:For Being a :sign0104:

Cheers :D
 

Attachments

  • Duel.zip
    10.1 KB · Views: 114

tsund

Member
Licensed User
Longtime User
I am having problems with the calculations part. I need to take values from the spinners and use them to calculate the amount of points deducted and the new total score value for that player. Also I need to be able to edit each players score individually. I know this code is wrong and I tried many many different ways, but none are working for me. I would appreciate some advice.
Thanks Erel

here is the part of code which doesnt work for me.

Sub Calculate
If Not (IsNumber(editPoints.Text)) Then
editPoints.Text = "0.0"
End If
If labelplayer1=1
labelplayer1=labelplayer1-editPoints.Text
If playerNum = 2
labelplayer2=labelplayer2-editPoints.Text
If playerNum = 3
labelplayer3=labelplayer3-editPoints.Text
If playerNum = 4
labelplayer4=labelplayer4-editPoints.Text

End Sub

playerNum is Spinner
labelplayer() is the player Number
And editPoints is the score to deduct
initialpoints in Spinner which sets initial point values
 
Upvote 0

JonPM

Well-Known Member
Licensed User
Longtime User
Your If statements aren't written correctly. Please see the beginners guide.
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
tsund .. Have a look at attached zip file ,I am unsure of what your trying to do calculations wise but this should give you a start at least.

I do suggest you follow JonPM 's advise and have a look at the beginners guide, and various code samples that are available.

Cheers mj
 

Attachments

  • Duel2.zip
    9.7 KB · Views: 142
Upvote 0

tsund

Member
Licensed User
Longtime User
Thanks

Thank you VERY much Mangojack. Ive been at this all week, ive figured most the coding out myself and fixed a lot since that last post. However your post was very informative. It helped me figure out what im doing, now i got to get to work using that code and working it into my app. Thanks for the help, I couldn't have asked for more. For now I am a very happy man!
 
Upvote 0

tsund

Member
Licensed User
Longtime User
Thanks a Million

Hey Mangojack
I just finished my app! Its working and running very well. No better feeling than that! I would like to thank you again for your support. I am going to continue learning b4a after this experience, I am motivated to make more applications. Haha, once I learn the lingo I hope to help others on these awesome forums. See you later!
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
Glad to be of help. Good luck for future apps.
Cheers mj
 
Upvote 0
Top