Object Initialization Question

Ksmith1192

Member
Licensed User
Longtime User
HI guys,

So I have a calculator program, and everytime I try to test it on the emulator, it gives me an error with the following code
B4X:
 Timer1_Tick
    Dim price,pounds,results As Float
    price = PriceLabel.Text 
    If PriceButtonDown Then 
        If PriceButtonPressed ="Increase" Then 
            price = price + .05
        Else
         If price>0 Then
               price = price - .05
         End If
        End If
        PriceLabel.Text = NumberFormat(price,0,2)
    End If

It highlights the price = PriceLabel.Text and says I have to initialize the label. What should I do to correct this?
 

Ksmith1192

Member
Licensed User
Longtime User
Here is my app. Whenever i try to emulate it, it pauses at the code outlined above. Thanks Klaus!
 

Attachments

  • Questions.zip
    181 KB · Views: 142
Upvote 0

klaus

Expert
Licensed User
Longtime User
Here you are.

You hade the initialization and adding of pnlMain in the condition below
If StateManager.RestoreState(Activity, "Main", 60) = False Then
When StateManager.RestoreState(Activity, "Main", 60) = True no pnlMain no layout loaded and as the timer is enabled you got the error.

I sent you code here some time ago but you never used it ?

Best regards.
 

Attachments

  • Questions1.zip
    181.2 KB · Views: 147
Upvote 0
Top