Variable default assignment

Azlan

Member
Licensed User
Longtime User
Will there be in a future version the ability to declare a variable with a default value i.e.

Dim MyVal as Int = 1 etc.

Typing separate variable assignments aside, this would also allow cut and paste from existing vb.net programs.

Cheers.
 

Kevin

Well-Known Member
Licensed User
Longtime User
I mentioned this in another thread since Java does this anyway it would make sense. From what I recall Java doesn't automatically 0 or "" variables either and there must be some code already setting the variables to a default of 0 or empty string, so us later setting a default means the Java code most likely sets it twice.

I'm not so sure that B4A or apps made with it set variables to 0 or "" by default, at least not on all Android builds. Reason being, I had recently added a new option to my app and later found that on at least one AVD, the variable defaulted to null, which caused an error when that value was saved to a json config file then later loaded in. The fix was to manually set it to 0 myself through code.
 
Top