B4R behaves in such a different way that sometimes we forget about it...
I was trying to define an empty string and then after define its value... But that is NOT possible in B4R...
So I searched a bit, and found out that I could use a string array instead, and since the values I need are known, It works like a charm!
B4X:
Private XDirection() As String = Array As String("Left","Right")
Private YDirection() As String = Array As String("Up","Down")
Objects created inside regular subs are created on the stack. You cannot assign a stack object to a global variable as the stack object will be invalid when the sub completes.
One solution is to declare a global array with the possible values and then have an index variable (Int) that points to the correct value.
Another option is to use ByteConverter.ObjectCopy to copy the object from the stack to the global variable. However for this to work properly the global variable should point to an object that is large enough to hold the new data.