I have been using Visual Studio for 12+ years. This is my first go around with B4A. I can't seem to find the right answer for creating structures. For example, in Visual Studio
Structure PersonDefinition
Dim Name as String
Dim Address as String
Dim City as String
Dim Age as Integer
End Structure
Dim Person() as PersonDefinition
So I can have Person(0) as a person, Person(1) as a different person, etc.
Person(0).Name = "Kevin"or Person(1).Age = 30.
If I want to sort that array, I can create keys for the sorting by column, such as age.
The only way I found (so far) to create this structure in B4A is:
Dim PersonDefinition(Name as String, Address as String, City as String, Age as Int)
Dim Person() as PersonDefinition
If this is the right way, then how would I sort this by age, or alphabetically by name?
I found one place that said to put it in a list, then sort the list. I did that, and it worked, to a degree.
However, I couldn't just use MySortList(0).Name to get the info I need.
It's very clear to me that the terminology is vastly different for the same thing, such as in VS, they are Forms, where B4A is Pages.
I can't seem to locate the proper term for structures. I have read about arrays, collections, and maps. But they aren't very clear. I guess it's just not clicking yet.
Also, my example is shortened. In my "structure", I have far more declaration, such as First Name, Last Name, Address, City, State, Zip, Email, Phone, and so on.
While there are a number of coding similarities, this really isn't visual basic. At least not the one I know.
One more obstacle, My Person declaration itself is multi-array.
Dim Person(5, 20) as PersonDefinition
Kinda hard to explain why I am doing this. I have an event with contestants, and the first array represents each round of competition.
People get eliminated each round, so the second declaration (20) will decrease each round.
I need to be able to sort this mess. I could do this all day long in VS, but things are different here.
I almost never ask for help in a forum, but I am stumped.
Can anyone shed some light on what I have right, wrong, and what I should be doing instead.
Thanks
Structure PersonDefinition
Dim Name as String
Dim Address as String
Dim City as String
Dim Age as Integer
End Structure
Dim Person() as PersonDefinition
So I can have Person(0) as a person, Person(1) as a different person, etc.
Person(0).Name = "Kevin"or Person(1).Age = 30.
If I want to sort that array, I can create keys for the sorting by column, such as age.
The only way I found (so far) to create this structure in B4A is:
Dim PersonDefinition(Name as String, Address as String, City as String, Age as Int)
Dim Person() as PersonDefinition
If this is the right way, then how would I sort this by age, or alphabetically by name?
I found one place that said to put it in a list, then sort the list. I did that, and it worked, to a degree.
However, I couldn't just use MySortList(0).Name to get the info I need.
It's very clear to me that the terminology is vastly different for the same thing, such as in VS, they are Forms, where B4A is Pages.
I can't seem to locate the proper term for structures. I have read about arrays, collections, and maps. But they aren't very clear. I guess it's just not clicking yet.
Also, my example is shortened. In my "structure", I have far more declaration, such as First Name, Last Name, Address, City, State, Zip, Email, Phone, and so on.
While there are a number of coding similarities, this really isn't visual basic. At least not the one I know.
One more obstacle, My Person declaration itself is multi-array.
Dim Person(5, 20) as PersonDefinition
Kinda hard to explain why I am doing this. I have an event with contestants, and the first array represents each round of competition.
People get eliminated each round, so the second declaration (20) will decrease each round.
I need to be able to sort this mess. I could do this all day long in VS, but things are different here.
I almost never ask for help in a forum, but I am stumped.
Can anyone shed some light on what I have right, wrong, and what I should be doing instead.
Thanks