Choose

LucaMs

Expert
Licensed User
Longtime User
I wanted to post some snippets to help us all.

So I went to look through the VB.Net functions, hoping to find some for B4A.

This is beautiful, very useful (unfortunately the description is in Italian):

upload_2014-12-16_1-10-35.png


warning: DO NO USE SOMETHING LIKE:

Dim MyArray() As String
...
Dim Word As String = MyArray(4)

USE:
Dim Word As String = Choose(4, MyArray)


:p

:eek:
 

LucaMs

Expert
Licensed User
Longtime User
I had too much hurry (as usual :p)
It could be useful in rare cases.

Choose(Index As Double, ParamArray Choise() As Object) As Object
Selects and returns a value form a list of parameters.
Index: Needed. Double. Numeric expression - must be a number between 1 and the number of elements of Choice.

But Choice is not an Array, it is a ParamArray. This means that you could use:

Dim Obj As Object = Choice(4, "Hello", 5, lvwItems, ... )
 
Last edited:
Top