Android Question How to store 2 strings in one variable and (please read post)

derez

Expert
Licensed User
Longtime User
There are several options, here are some:
1. Store a string with a comma separating the two values: dim var as string = "Apple,http://www.apple.com" , then use:
dim str() as string = regex.split(",", var)
the first string will be in str(0) and the second in str(1)
2. Define a type (in globals) -
Type dblstring(name As String,link As String)
dim var as dblstring
and use var.name = "Apple"
var.link = "http://www.apple.com"
3. Use my Keyvalues class which is a modification of KeyValueStore. https://www.b4x.com/android/forum/threads/keyvalues-extended-keyvaluestore.32553/
 
Upvote 0

Rajesh kannan MJ

Member
Licensed User
Longtime User
Is this kind of 2 dimensional array possible in b4a please

B4X:
$cars = array
  (
  array("Volvo",22,18),
  array("BMW",15,13),
  array("Saab",5,2),
  array("Land Rover",17,15)
  );
 
Upvote 0

James Chamblin

Active Member
Licensed User
Longtime User
Use maps
B4X:
    Dim m As Map
    m.Initialize
    m.Put("Apple","http://www.apple.com")
    m.Put("Google","http://www.google.com")
    Log(m.Get("Apple"))
    Log(m.Get("Google"))
 
Upvote 0
Top