How to add numbers to a number

B4X:
Sub ImageView1_Click
   Select Msgbox2("Would You Like To By This?" , "Conferm Order" , "yes","Cancel" , "no" ,LoadBitmap(File.DirAssets,"bud_icon_007.jpg"))    
    
     Case DialogResponse.POSITIVE
      money1 = money1 - "20"
      label1.Text = ""
      label1.Text = "$" & money1
      imageview1.Bitmap = LoadBitmap(File.DirAssets,"bud1owned.jpg")
      ownedamountitem1 = ownedamountitem1 + "1"
      imageview3.Bitmap = LoadBitmap(File.DirAssets,"bud_icon_007.jpg")
      labelitemamount1.Text = ownedamountitem1
    Case DialogResponse.NEGATIVE
        
    Case Else
        ToastMessageShow("No",False)
End Select
End Sub
see my problem is here
B4X:
ownedamountitem1 = ownedamountitem1 + "1"
 

stevel05

Expert
Licensed User
Longtime User
You don't need quotes around the numbers.

If money > 0 then
'Do something
End If

-------------------
Sent via Tapatalk
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Have you loaded a layout that contains a label?

Activity.Loadlayout("1.bal")

-------------------
Sent via Tapatalk
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Can you post your code? Zip it first from the file menu.

-------------------
Sent via Tapatalk
 
Upvote 0

yttrium

Active Member
Licensed User
Longtime User
can you fix the errors and post back the code?

We won't fix your code for you, but we'll show you how to fix it. The point is that you learn.

From what I can see, nowhere in your layout do you have a label named Label1 - you have one named Label2, however.

Rename Label2 to Label1 and your issue should be fixed.
 
Last edited:
Upvote 0

yttrium

Active Member
Licensed User
Longtime User
Nah I have a labelbox1 but not a 2

Oh, it's just hidden - you have Label1 and Label2.

Go to your Globals and note how you say:

B4X:
   Dim label1 As Label

Strings are case sensitive. Changing "label1" to "Label1" will fix your issue.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
The program won't run as it is, there are errors. If you run it in debug mode, it'll give you a line number and you can fix each one in turn. The first on is an error with the MsgBox syntax. You've had a few suggestions, implement these first then if you find a problem you can't identify post again, with the amended code so we don't all have to do it.
 
Upvote 0
Ok i fixed most of the errors but there are two errors when you run on your phone take a look can you please help
 

Attachments

  • code.zip
    208.4 KB · Views: 163
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Then error I get is at:

money.Visible = True

You have a Dim for a label called money, but it's not in the loaded layout 1.

There is one in the homescreen layout but you haven't loaded that.

How you sort this is a matter of design.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Yes although they are two separate errors.

As I said the first one is because you do not have Label1 defined in the Layout you have loaded.

The second is because you are still adding "1" (in quotes) in line 128:

B4X:
labelitemamount1.Text + "1"

It should be:

B4X:
labelitemamount1.Text + 1
 
Upvote 0
Top