Android Question Initialize not recognized

Shelby

Well-Known Member
Licensed User
Longtime User
As usual I'm trying to learn by using Erel's tutorials. When trying to follow along with my B4A program, B4A won't recognize the word Initialize. I thought we used Initialize on an earlier tutorial but this one is not working. Any ideas? It's the 11th tutorial 'Codes Modules and Classes". As you may know Erel uses B4J and I'm using B4A.
Thanks
[
Sub Process_Globals

End Sub
Sub Globals

End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim c1, c2 As Class1
c1.Initialize
c1.value = 200
c2.Initialize
c2.value = 300
c1.LogValue
c2.LogValue
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
]
 

Shelby

Well-Known Member
Licensed User
Longtime User
Thanks Luca,
Here's my class1 code

[
Sub Class_Globals
Public value As Int
End Sub
'Initializes the object.
Public Sub LogValue
Log(value)
End Sub
]
 
Upvote 0

Shelby

Well-Known Member
Licensed User
Longtime User
Yes, I have done that as directed by the tutorial. It seems to be saved in my files as class1.bas
 
Upvote 0

Shelby

Well-Known Member
Licensed User
Longtime User
Now of course I didn't know if I should add the new sub on the class1 tab or the Main tab so I put it into the main tab as seen below. Still it's not happy when I run the (uh oh I have release instead of debug from the last tutorial. I'll change release to debug).

[
Sub Process_Globals
End Sub
Sub Globals
End Sub

Sub Initialize
End Sub

Sub Activity_Create(FirstTime As Boolean)
Dim c1, c2 As Class1
c1.Initialize
c1.value = 200
c2.Initialize
c2.value = 300
c1.LogValue
c2.LogValue
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
]
 
Last edited:
Upvote 0

Shelby

Well-Known Member
Licensed User
Longtime User
Nope didn't work plus I see Erel has Release in the box.
Aha!! It worked when I added the new sub on the Class tab.
Thanks again for your assistance!
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
You must add it in the Class module.

Two advices:
1. You should use code tags when posting code.


2. It is most often more efficient to post a test project, as a zip file, showing the problem.
Creating a zip file of the project.
 
Upvote 0

Shelby

Well-Known Member
Licensed User
Longtime User
B4X:
The code

Oh, I now see to use the icon in the list (not just put [] around my code). I guess either style works as long as the words code and /code are within the brackets.
Thanks Don
 
Last edited:
Upvote 0

Shelby

Well-Known Member
Licensed User
Longtime User
Klaus, I also see the value of large file segments being put into a zip file.
Thanks
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…